v.net.steiner(1grass)
✨ v.net.steiner 💅
okay bestie, welcome to v.net.steiner, straight outta the GRASS User's Manual 🌸 this lil icon creates a Steiner tree for your network plus whatever terminals you hand it.
and bestie, real talk before we even start: the 'Minimum Steiner Tree' problem is NP-hard, and this module uses a heuristic algorithm — so the result may be sub optimal. not a bug, just math being math 😭 no cap.
🎀 KEYWORDS
vector, network, steiner tree — that's the whole vibe ✨
🌈 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 (little switches, big energy)
-g— use geodesic calculation for longitude-latitude projects 🌍--overwrite— let output files overwrite existing files (yes queen, bulldoze it)--help— print usage summary--verbose— verbose module output (she talks a lot 💬)--quiet— quiet module output (she says nothing 💀)--ui— force launching GUI dialog
💖 PARAMETERS (the actual important stuff)
input=name[required] — name of input vector map. Or a data source for direct OGR access.output=name[required] — name for output vector map. name it something cute 🫶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 picks which layer to use. When used with direct OGR access, this is the layer name. Default:1.node_layer=string— node layer (used for terminals, iykyk). Same deal: features can carry categories in different layers, this picks which one. With direct OGR access this is the layer name. Default:2.acolumn=string— the arcs' cost column (for both directions) 💸terminal_cats=range[required] — category values. Categories of points on terminals (the 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. slay.
A Steiner tree is used to calculate the minimum-cost vector network connecting some number of end nodes in a network framework. For example, it could be used to find the path following a road system which will minimize the amount of fibre optic cable needed to connect a series of satellite offices. literally infrastructure queen behavior 👑
Costs may be either line lengths, or attributes saved in a database table. These attribute values are taken as costs of whole segments, not as costs to traverse a length unit (e.g. meter) of the segment. For example, if the speed limit is 100 km / h, the cost to traverse a 10 km long road segment must be calculated as length / speed = 10 km / (100 km/h) = 0.1 h. Supported are cost assignments for both arcs and nodes. For areas, costs will be 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 skipping this step bestie, she will not find your points otherwise 🙈
👑 NOTES
the current implementation of obtaining a Steiner tree is not memory efficient. An attempt to run the module on a network with a large number of intersections might therefore result in failure to allocate memory or an out-of-memory condition. 💀
fr fr, if your network is thicc, your RAM might simply leave the chat. plan accordingly 🫶
🧚 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 🫶 go say hi)
⭐ AUTHORS
- Radim Blazek, ITC-Irst, Trento, Italy
- Documentation: Markus Neteler, Markus Metz
🌈 SOURCE CODE
Available at: v.net.steiner source code (history)
Latest change: Thursday Feb 13 14:10:24 2025 in commit: c0fe7d746d0e4b334ec160652469b3ced51e03b2
Main index | Vector index | Topics index | Keywords index | Graphical index | Full index
and that's the whole page bestie 💖 this was v.net.steiner(1grass) from the GRASS User's Manual, GRASS 8.5.0, © 2003-2026 GRASS Development Team, GRASS 8.5.0 Reference Manual. periodt. 🎀✨
📦 where this page comes from
- alpine 3.24: grass-gis-doc 8.5.0-r1 · GPL-2.0-or-later
- ubuntu stonking: grass-doc 8.5.0-1ubuntu1 · 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