d.path
Finds shortest path for selected starting and ending node.
d.path [-gb] map=name [arc_type=string [,string,...]] coordinates=x1,y1,x2,y2 [arc_layer=string] [node_layer=string] [arc_column=string] [arc_backward_column=string] [node_column=string] [highlight_color=string] [--verbose] [--quiet] [--qq] [--ui]
Example:
d.path map=name coordinates=x1,y1,x2,y2
grass.script.parse_command("d.path", map, arc_type="line,boundary", coordinates, arc_layer="1", node_layer="2", arc_column=None, arc_backward_column=None, node_column=None, highlight_color="red", flags=None, verbose=False, quiet=False, superquiet=False)
Example:
gs.parse_command("d.path", map="name", coordinates=x1,y1,x2,y2)
Parameters
map=name [required]
Name of vector map
Or data source for direct OGR access
arc_type=string [,string,...]
Arc type
Allowed values: line, boundary
Default: line,boundary
coordinates=x1,y1,x2,y2 [required]
Starting and ending coordinates
arc_layer=string
Arc layer
Vector features can have category values in different layers. This number determines which layer to use. When used with direct OGR access this is the layer name.
Default: 1
node_layer=string
Node layer
Vector features can have category values in different layers. This number determines which layer to use. When used with direct OGR access this is the layer name.
Default: 2
arc_column=string
Arc forward/both direction(s) cost column (number)
arc_backward_column=string
Arc backward direction cost column (number)
node_column=string
Node cost column
highlight_color=string
Highlight color
Default: red
-g
Use geodesic calculation for longitude-latitude locations
-b
Render bold lines
--help
Print usage summary
--verbose
Verbose module output
--quiet
Quiet module output
--qq
Very quiet module output
--ui
Force launching GUI dialog
map : str, required
Name of vector map
Or data source for direct OGR access
Used as: input, vector, name
arc_type : str | list[str], optional
Arc type
Allowed values: line, boundary
Default: line,boundary
coordinates : tuple[float, float, float, float] | list[float] | str, required
Starting and ending coordinates
Used as: input, coords, x1,y1,x2,y2
arc_layer : str, optional
Arc layer
Vector features can have category values in different layers. This number determines which layer to use. When used with direct OGR access this is the layer name.
Used as: input, layer
Default: 1
node_layer : str, optional
Node layer
Vector features can have category values in different layers. This number determines which layer to use. When used with direct OGR access this is the layer name.
Used as: input, layer
Default: 2
arc_column : str, optional
Arc forward/both direction(s) cost column (number)
arc_backward_column : str, optional
Arc backward direction cost column (number)
node_column : str, optional
Node cost column
highlight_color : str, optional
Highlight color
Used as: color
Default: red
flags : str, optional
Allowed values: g, b
g
Use geodesic calculation for longitude-latitude locations
b
Render bold lines
verbose: bool, optional
Verbose module output
Default: False
quiet: bool, optional
Quiet module output
Default: False
superquiet: bool, optional
Very quiet module output
Default: False
DESCRIPTION
d.path enables shortest path vector networking. Costs may be either line lengths, or attributes saved in a database table. Supported are cost assignments for both arcs and nodes, and also different in both directions of a vector line. For areas cost will be calculated along boundary lines.
NOTE
The user needs to display a vector map before using d.path. If no
graphics monitor is open, a file map.png
is generated in the current
directory.
The 'from' and 'to' points are entered by mouse into the map displayed in the GRASS monitor, or if the coordinates option is used they can be specified non-interactively. The actions bound to the mouse buttons are described in the terminal window when running the command.
To calculate shortest path non-interactively and save the path to a new vector map, use the v.net.path module.
EXAMPLES
Interactive shortest path routing on road network (North Carolina sample dataset):
g.region vector=roadsmajor -p
d.vect roadsmajor
d.path roadsmajor coordinates=668646.15,224447.16,668348.83,235894.02
Non-interactive shortest path routing on road network (North Carolina sample dataset):
d.path -b roadsmajor coordinates=668646.15,224447.16,668348.83,235894.02
SEE ALSO
AUTHOR
Radim Blazek, ITC-Irst, Trento, Italy
SOURCE CODE
Available at: d.path source code
(history)
Latest change: Friday Feb 07 19:16:09 2025 in commit a82a39f