1v.net.path(1)               GRASS GIS User's Manual              v.net.path(1)
2
3
4

NAME

6       v.net.path  - Finds shortest path on vector network.
7

KEYWORDS

9       vector, network, shortest path
10

SYNOPSIS

12       v.net.path
13       v.net.path --help
14       v.net.path     [-tgs]     input=name    output=name    arc_layer=string
15       arc_type=string[,string,...] node_layer=string  [file=name]   [arc_col‐
16       umn=string]      [arc_backward_column=string]      [node_column=string]
17       [dmax=float]   [turn_layer=string]   [turn_cat_layer=string]   [--over‐
18       write]  [--help]  [--verbose]  [--quiet]  [--ui]
19
20   Flags:
21       -t
22           Use turntable
23
24       -g
25           Use geodesic calculation for longitude-latitude locations
26
27       -s
28           Write output as original input segments, not each path as one line.
29
30       --overwrite
31           Allow output files to overwrite existing files
32
33       --help
34           Print usage summary
35
36       --verbose
37           Verbose module output
38
39       --quiet
40           Quiet module output
41
42       --ui
43           Force launching GUI dialog
44
45   Parameters:
46       input=name [required]
47           Name of input vector map
48           Or data source for direct OGR access
49
50       output=name [required]
51           Name for output vector map
52
53       arc_layer=string [required]
54           Arc layer
55           Vector  features can have category values in different layers. This
56           number determines which layer to use. When  used  with  direct  OGR
57           access this is the layer name.
58           Default: 1
59
60       arc_type=string[,string,...] [required]
61           Arc type
62           Input feature type
63           Options: line, boundary
64           Default: line,boundary
65
66       node_layer=string [required]
67           Node layer
68           Vector  features can have category values in different layers. This
69           number determines which layer to use. When  used  with  direct  OGR
70           access this is the layer name.
71           Default: 2
72
73       file=name
74           Name  of  file  containing start and end points. If not given, read
75           from stdin
76
77       arc_column=string
78           Arc forward/both direction(s) cost column (number)
79
80       arc_backward_column=string
81           Arc backward direction cost column (number)
82
83       node_column=string
84           Node cost column (number)
85
86       dmax=float
87           Maximum distance to the network
88           If start/end are given as coordinates. If start/end point  is  out‐
89           side  this  threshold,  the  path is not found and error message is
90           printed. To speed up the process, keep this value as low as  possi‐
91           ble.
92           Default: 1000
93
94       turn_layer=string
95           Layer with turntable
96           Relevant only with -t flag
97           Default: 3
98
99       turn_cat_layer=string
100           Layer with unique categories used in turntable
101           Relevant only with -t flag
102           Default: 4
103

DESCRIPTION

105       v.net.path determines least costly, e.g. shortest or fastest path(s) on
106       a vector network.
107
108       Costs may be either line lengths, or attributes saved in a database ta‐
109       ble.  These  attribute values are taken as costs of whole segments, not
110       as costs to traverse a length unit (e.g. meter) of  the  segment.   For
111       example, if the speed limit is 100 km / h, the cost to traverse a 10 km
112       long road segment must be calculated as
113       length / speed = 10 km / (100 km/h) = 0.1 h.
114       Supported are cost assignments for both arcs and nodes, and  also  dif‐
115       ferent  costs  for  both directions of a vector line.  For areas, costs
116       will be calculated along boundary lines.
117
118       The input vector needs to be prepared with v.net  operation=connect  in
119       order to connect points representing center nodes to the network.
120
121       Nodes and arcs can be closed using cost = -1.
122
123       Least  cost paths are written to the output vector map with an attached
124       attribute table.
125
126       Nodes can be
127
128           ·   piped into the program from file or from stdin, or
129
130           ·   defined in the graphical user interface ("enter values interac‐
131               tively").
132       The syntax is as follows:
133       id start_point_category end_point_category
134       (Example: 1 1 2)
135
136       or
137       id start_point_x start_point_y end_point_x end_point_y
138
139       Points  specified by category must be exactly on network nodes, and the
140       input vector map needs to be prepared with v.net operation=connect.
141
142       When specifying coordinates, the next network node to a  given  coordi‐
143       nate pair is used.
144
145       The attribute table will contain the following attributes:
146
147           ·   cat  - path unique category assigned by module
148
149           ·   id   - path id (read from input)
150
151           ·   fcat - from point category
152
153           ·   tcat - to point category
154
155           ·   sp - result status:
156
157               ·   0 - OK, path found
158
159               ·   1 - node is not reachable
160
161               ·   2 - point of given category does not exist
162
163           ·   cost - travelling costs (on the network, not to/from network)
164
165           ·   fdist - the distance from first point to the network
166
167           ·   tdist - the distance from the network to second point
168
169       Application of flag -t enables a turntable support.  This flag requires
170       additional parameters turn_layer and turn_cat_layer that are  otherwise
171       ignored.   The  turntable allows to model e.g. traffic code, where some
172       turns may be prohibited.  This means that the input layer  is  expanded
173       by  turntable  with  costs  of every possible turn on any possible node
174       (intersection) in both directions.  Turntable can  be  created  by  the
175       v.net  module.   For more information about turns in the vector network
176       analyses see wiki page.
177

NOTES

179       Nodes and arcs can be closed using cost = -1.
180
181       If the cost columns arc_column, arc_backward_column and node_column are
182       not  specified,  the  length  of  network segments is measured and zero
183       costs are assumed for nodes.
184
185       When using attributes, the length of segments is not used. To get accu‐
186       rate results, the line length must be taken into account when assigning
187       costs as attributes. For example, to get the fastest path, the  columns
188       ’max_speed’  and  ’length’  are  required. The correct fastest path can
189       then be found by specifying  arc_column=length/max_speed.  If  not  yet
190       existing, the column containing the line length ("length") has to added
191       to the attributes table using v.to.db.
192

EXAMPLE

194       Shortest (red) and fastest (blue)  path  between  two  digitized  nodes
195       (Spearfish):
196
197       # Spearfish
198       echo "1|601955.1|4916944.9|start
199       2|594385.6|4921565.2|end" | v.in.ascii in=- cat=1 x=2 y=3 out=startend col="cat integer, \
200                                east double precision, north double precision, label varchar(6)"
201       v.db.select startend
202       g.copy vect=roads,myroads
203       # create lines map connecting points to network
204       v.net myroads points=startend out=myroads_net op=connect thresh=500 arc_layer=1 node_layer=2
205       # set up costs
206       # create unique categories for each road in layer 3
207       v.category in=myroads_net out=myroads_net_time opt=add cat=1 layer=3 type=line
208       # add new table for layer 3
209       v.db.addtable myroads_net_time layer=3 col="cat integer,label varchar(43),length double precision,speed double precision,cost double precision,bcost double precision"
210       # copy road type to layer 3
211       v.to.db myroads_net_time layer=3 qlayer=1 opt=query qcolumn=label columns=label
212       # upload road length in miles
213       v.to.db myroads_net_time layer=3 type=line option=length col=length unit=miles
214       # set speed limits in miles / hour
215       v.db.update myroads_net_time layer=3 col=speed val="5.0"
216       v.db.update myroads_net_time layer=3 col=speed val="75.0" where="label=’interstate’"
217       v.db.update myroads_net_time layer=3 col=speed val="75.0" where="label=’primary highway, hard surface’"
218       v.db.update myroads_net_time layer=3 col=speed val="50.0" where="label=’secondary highway, hard surface’"
219       v.db.update myroads_net_time layer=3 col=speed val="25.0" where="label=’light-duty road, improved surface’"
220       v.db.update myroads_net_time layer=3 col=speed val="5.0" where="label=’unimproved road’"
221       # define traveling costs as traveling time in minutes:
222       # set forward costs
223       v.db.update myroads_net_time layer=3 col=cost val="length / speed * 60"
224       # set backward costs
225       v.db.update myroads_net_time layer=3 col=bcost val="length / speed * 60"
226       # ... the ’start’ and ’end’ nodes have category number 1 and 2
227       # Shortest path: ID as first number, then cat1 and cat2
228       echo "1 1 2" | v.net.path myroads_net_time arc_layer=3 node_layer=2 out=mypath
229       # Fastest path: ID as first number, then cat1 and cat2
230       echo "1 1 2" | v.net.path myroads_net_time arc_layer=3 node_layer=2 arc_column=cost arc_backward_column=bcost out=mypath_time
231       To display the result, run for example:
232       g.region vector=myroads_net
233       d.mon x0
234       d.vect myroads_net
235       # show shortest path
236       d.vect mypath col=red width=2
237       # show fastest path
238       d.vect mypath_time col=blue width=2
239       # start and end point
240       d.vect myroads_net icon=basic/triangle fcol=green size=12 layer=2
241       d.font font=Vera
242       d.vect startend disp=cat type=point lsize=14 layer=2
243

SEE ALSO

245         d.path, v.net, v.net.alloc, v.net.iso, v.net.salesman, v.net.steiner,
246       v.to.db
247

AUTHORS

249       Radim Blazek, ITC-Irst, Trento, Italy
250       Documentation: Markus Neteler, Markus Metz
251
252   TURNS SUPPORT
253       The turns support was implemnented as part  of  GRASS  GIS  turns  cost
254       project at Czech Technical University in Prague, Czech Republic.
255
256       Implementation: Stepan Turek
257       Documentation: Lukas Bocan, Eliska Kyzlikova, Viera Bejdova
258       Mentor: Martin Landa
259

SOURCE CODE

261       Available at: v.net.path source code (history)
262
263       Main  index  | Vector index | Topics index | Keywords index | Graphical
264       index | Full index
265
266       © 2003-2020 GRASS Development Team, GRASS GIS 7.8.5 Reference Manual
267
268
269
270GRASS 7.8.5                                                      v.net.path(1)
Impressum