v.net.steiner(1)
๐ v.net.steiner ๐ โ GRASS GIS User's Manual, bestie edition
hiii so this is the manual page for v.net.steiner(1), straight out of the GRASS GIS User's Manual ๐ it's the little module that builds you a Steiner tree on a network, and honestly? it's giving graph theory main character energy. let's get into it ๐ธ
โจ NAME โจ
v.net.steiner โ creates a Steiner tree for the network and the given terminals, periodt.
๐จ real talk: the 'Minimum Steiner Tree' problem is NP-hard, and this module uses a heuristic algorithm, so the result may be sub optimal. no cap. it's doing its best, okay? ๐ญ
๐ KEYWORDS ๐
vector, network, steiner tree ๐ฆ
๐ SYNOPSIS ๐
v.net.steiner
v.net.steiner --help
v.net.steiner [-g] input=name output=name
[arc_type=string[,string,...]] [arc_layer=string]
[node_layer=string] [acolumn=string] terminal_cats=range
[npoints=integer] [--overwrite] [--help] [--verbose] [--quiet]
[--ui]
๐ฉ Flags ๐ฉ
-gโ use geodesic calculation for longitude-latitude projects ๐--overwriteโ allow output files to overwrite existing files (be careful, bestie, this one does exactly what it says ๐ )--helpโ print usage summary--verboseโ verbose module output--quietโ quiet module output--uiโ force launching GUI dialog
๐ Parameters ๐
input=name[required] โ name of input vector map. or, alternatively, data source for direct OGR access.output=name[required] โ name for output vector map.arc_type=string[,string,...]โ arc type / input feature type. options:line,boundary. default:line,boundary.arc_layer=stringโ arc layer. vector features can have category values in different layers, and this number decides which layer to use. when you're working with direct OGR access, this is the layer name instead. default:1.node_layer=stringโ node layer (used for terminals). same deal as above: vector features can carry category values in different layers, and this number picks which layer. with direct OGR access it's the layer name. default:2.acolumn=stringโ arcs' cost column (for both directions) ๐terminal_cats=range[required] โ category values. these are the categories of points on terminals (layer is specified bynlayer).npoints=integerโ number of Steiner points (-1for all possible). default:-1.
๐ DESCRIPTION ๐
v.net.steiner calculates the optimal connection of nodes on a vector network. that's the whole vibe.
A Steiner tree is the tool you reach for when you need the minimum-cost vector network that connects some number of end nodes inside a network framework. like, imagine you're laying fibre optic cable and you need to connect a bunch of satellite offices while following the road system โ this is the module that minimizes how much cable you gotta buy. iconic, honestly ๐ซถ
Costs can be either line lengths or attributes saved in a database table. quick note though: those attribute values are taken as the cost of whole segments, not as a cost to traverse a length unit (like a meter) of the segment. so for example, if the speed limit is 100 km / h, the cost to traverse a 10 km long road segment has to be calculated as length / speed = 10 km / (100 km/h) = 0.1 h. do the math, bestie, don't skip it ๐ค
Supported are cost assignments for both arcs and nodes. and for areas? the costs get calculated along boundary lines. ๐ง
Points representing nodes must be exactly on network nodes, and the input vector map needs to be prepared with v.net operation=connect. no shortcuts here, sorry ๐ญ
๐ง NOTES ๐ง
The current implementation of obtaining the Steiner tree is not memory efficient. so if you try to run this module on a network with a large number of intersections, you might fail to allocate memory or hit an out-of-memory condition. ๐ตโ๐ซ be nice to your RAM.
๐ EXAMPLE ๐
Steiner tree for 6 digitized nodes (Spearfish):
Shortest path, along unimproved roads:
Fastest path, along highways:
# Spearfish
g.copy vect=roads,myroads
# we have 6 locations to allocate
echo "1|601653.5|4922869.2|a
2|608284|4923776.6|b
3|601845|4914981.9|c
4|596270|4917456.3|d
5|593330.8|4924096.6|e
6|598005.5|4921439.2|f" | v.in.ascii in=- cat=1 x=2 y=3 out=centers col="cat integer, \
east double precision, north double precision, label varchar(43)"
v.db.select centers
v.category centers op=report
# type count min max
# point 6 1 6
# create lines map connecting points to network (on layer 2)
v.net myroads points=centers out=myroads_net op=connect thresh=500
# set up costs as traveling time
# create unique categories for each road in layer 3
v.category in=myroads_net out=myroads_net_time opt=add cat=1 layer=3 type=line
# add new table for layer 3
v.db.addtable myroads_net_time layer=3 col="cat integer,label varchar(43),length double precision,speed double precision,cost double precision"
# copy road type to layer 3
v.to.db myroads_net_time layer=3 qlayer=1 opt=query qcolumn=label columns=label
# upload road length in miles
v.to.db myroads_net_time layer=3 type=line option=length col=length unit=miles
# set speed limits in miles / hour
v.db.update myroads_net_time layer=3 col=speed val="5.0"
v.db.update myroads_net_time layer=3 col=speed val="75.0" where="label=โinterstateโ"
v.db.update myroads_net_time layer=3 col=speed val="75.0" where="label=โprimary highway, hard surfaceโ"
v.db.update myroads_net_time layer=3 col=speed val="50.0" where="label=โsecondary highway, hard surfaceโ"
v.db.update myroads_net_time layer=3 col=speed val="25.0" where="label=โlight-duty road, improved surfaceโ"
v.db.update myroads_net_time layer=3 col=speed val="5.0" where="label=โunimproved roadโ"
# define traveling costs as traveling time in minutes:
v.db.update myroads_net_time layer=3 col=cost val="length / speed * 60"
# shortest path
v.net.steiner myroads_net_time arc_layer=3 node_layer=2 terminal_cats=1-6 out=mysteiner_distance
# fastest path
v.net.steiner myroads_net_time arc_layer=3 node_layer=2 acol=cost terminal_cats=1-6 out=mysteiner_time
To display the result, run for example:
# display the results
g.region vector=myroads_net
# shortest path
d.mon x0
d.vect myroads_net
d.vect -c centers icon=basic/triangle
d.font Vera
d.vect centers col=red disp=attr attrcol=label lsize=12
d.vect mysteiner_distance col=blue width=2
# fastest path
d.mon x1
d.vect myroads_net
d.vect -c centers icon=basic/triangle
d.font Vera
d.vect centers col=red disp=attr attrcol=label lsize=12
d.vect mysteiner_time col=blue width=2
๐ SEE ALSO ๐
d.path, v.net, v.net.alloc, v.net.iso, v.net.path, v.net.salesman
the whole network module friend group, fr fr ๐
๐ AUTHORS ๐
Radim Blazek, ITC-Irst, Trento, Italy
Documentation: Markus Neteler, Markus Metz
๐ฆ SOURCE CODE ๐ฆ
Available at: v.net.steiner source code (history)
Accessed: Saturday Jan 17 05:41:27 2026
Main index | Vector index | Topics index | Keywords index | Graphical index | Full index
okay that's the whole page bestie, you ate it ๐ and a lil sign-off for the credits: this is from GRASS GIS 8.4.2, the GRASS 8.4.2 Reference Manual, ยฉ 2003-2025 GRASS Development Team. go build some trees ๐๐ณโจ
๐ฆ where this page comes from
- fedora 44: grass 8.4.2-4.fc44 ยท GPL-2.0-or-later
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms