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 by nlayer).
  • npoints=integer โ€” number of Steiner points (-1 for 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