.TH v.net.path 1grass "" "GRASS 6.4.4" "Grass User's Manual" .SH NAME \fI\fBv.net.path\fR\fR - Finds shortest path on vector network. .SH KEYWORDS vector, network, shortest path .SH SYNOPSIS \fBv.net.path\fR .br \fBv.net.path help\fR .br \fBv.net.path\fR [\-\fBgs\fR] \fBinput\fR=\fIname\fR \fBoutput\fR=\fIname\fR [\fBtype\fR=\fIstring\fR[,\fIstring\fR,...]] [\fBalayer\fR=\fIinteger\fR] [\fBnlayer\fR=\fIinteger\fR] [\fBfile\fR=\fIname\fR] [\fBafcolumn\fR=\fIstring\fR] [\fBabcolumn\fR=\fIstring\fR] [\fBncolumn\fR=\fIstring\fR] [\fBdmax\fR=\fIfloat\fR] [\-\-\fBoverwrite\fR] [\-\-\fBverbose\fR] [\-\-\fBquiet\fR] .SS Flags: .IP "\fB\-g\fR" 4m .br Use geodesic calculation for longitude-latitude locations .IP "\fB\-s\fR" 4m .br Write output as original input segments, not each path as one line. .IP "\fB\-\-overwrite\fR" 4m .br Allow output files to overwrite existing files .IP "\fB\-\-verbose\fR" 4m .br Verbose module output .IP "\fB\-\-quiet\fR" 4m .br Quiet module output .PP .SS Parameters: .IP "\fBinput\fR=\fIname\fR" 4m .br Name of input vector map .IP "\fBoutput\fR=\fIname\fR" 4m .br Name for output vector map .IP "\fBtype\fR=\fIstring[,\fIstring\fR,...]\fR" 4m .br Arc type .br Options: \fIline,boundary\fR .br Default: \fIline,boundary\fR .IP "\fBalayer\fR=\fIinteger\fR" 4m .br Layer number .br Arc layer .br Default: \fI1\fR .IP "\fBnlayer\fR=\fIinteger\fR" 4m .br Layer number .br Node layer .br Default: \fI2\fR .IP "\fBfile\fR=\fIname\fR" 4m .br Name of file containing start and end points. If not given, read from stdin .IP "\fBafcolumn\fR=\fIstring\fR" 4m .br Arc forward/both direction(s) cost column .IP "\fBabcolumn\fR=\fIstring\fR" 4m .br Arc backward direction cost column .IP "\fBncolumn\fR=\fIstring\fR" 4m .br Node cost column .IP "\fBdmax\fR=\fIfloat\fR" 4m .br Maximum distance to the network .br If start/end are given as coordinates. If start/end point is outside this threshold, the path is not found and error message is printed. To speed up the process, keep this value as low as possible. .br Default: \fI1000\fR .PP .SH DESCRIPTION \fIv.net.path\fR determines least costly, e.g. shortest or fastest path(s) on a vector network. .PP 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 .br length / speed = 10 km / (100 km/h) = 0.1 h. .br Supported are cost assignments for both arcs and nodes, and also different costs for both directions of a vector line. For areas, costs will be calculated along boundary lines. .PP The input vector needs to be prepared with \fIv.net operation=connect\fR in order to connect points representing center nodes to the network. .PP Nodes and arcs can be closed using cost = -1. .PP Least cost paths are written to the output vector map with an attached attribute table. .PP Nodes can be .RS .IP piped into the program from file or from stdin, or .IP defined in the graphical user interface ("enter values interactively"). .RE The syntax is as follows: \fC .DS .br id start_point_category end_point_category .br .DE \fR (Example: 1 1 2) .PP or \fC .DS .br id start_point_x start_point_y end_point_x end_point_y .br .DE \fR .PP Points specified by category must be exactly on network nodes, and the input vector map needs to be prepared with \fIv.net operation=connect\fR. .PP When specifying coordinates, the next network node to a given coordinate pair is used. .PP The attribute table will contain the following attributes: .RS .IP cat - path unique category assigned by module .IP id - path id (read from input) .IP fcat - from point category .IP tcat - to point category .IP sp - result status: .RS .IP 0 - OK, path found .IP 1 - node is not reachable .IP 2 - point of given category does not exist .RE cost - travelling costs (on the network, not to/from network) fdist - the distance from first point to the network tdist - the distance from the network to second point .RE .SH NOTES Nodes and arcs can be closed using cost = -1. .PP If the cost columns 'afcol', 'abcol' and 'ncol' are not specified, the length of network segments is measured and zero costs are assumed for nodes. .PP When using attributes, the length of segments is not used. To get accurate results, the line length must be taken into account when assigning costs as attributes. For example, to get the \fBfastest path\fR, the columns 'max_speed' and 'length' are required. The correct fastest path can then be found by specifying afcol=length/max_speed. If not yet existing, the column containing the line length ("length") has to added to the attributes table using \fIv.to.db\fR. .SH EXAMPLE Shortest (red) and fastest (blue) path between two digitized nodes (Spearfish): .PP .PP \fC .DS .br # Spearfish .br .br echo "1|601955.1|4916944.9|start .br 2|594385.6|4921565.2|end" | v.in.ascii in=- cat=1 x=2 y=3 out=startend col="cat integer, \(rs .br east double precision, north double precision, label varchar(6)" .br .br v.db.select startend .br .br g.copy vect=roads,myroads .br .br # create lines map connecting points to network .br v.net myroads points=startend out=myroads_net op=connect thresh=500 alayer=1 nlayer=2 .br .br # set up costs .br .br # create unique categories for each road in layer 3 .br v.category in=myroads_net out=myroads_net_time opt=add cat=1 layer=3 type=line .br .br # add new table for layer 3 .br 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" .br .br # copy road type to layer 3 .br v.to.db myroads_net_time layer=3 qlayer=1 opt=query qcolumn=label columns=label .br .br # upload road length in miles .br v.to.db myroads_net_time layer=3 type=line option=length col=length unit=miles .br .br # set speed limits in miles / hour .br v.db.update myroads_net_time layer=3 col=speed val="5.0" .br v.db.update myroads_net_time layer=3 col=speed val="75.0" where="label='interstate'" .br v.db.update myroads_net_time layer=3 col=speed val="75.0" where="label='primary highway, hard surface'" .br v.db.update myroads_net_time layer=3 col=speed val="50.0" where="label='secondary highway, hard surface'" .br v.db.update myroads_net_time layer=3 col=speed val="25.0" where="label='light-duty road, improved surface'" .br v.db.update myroads_net_time layer=3 col=speed val="5.0" where="label='unimproved road'" .br .br # define traveling costs as traveling time in minutes: .br .br # set forward costs .br v.db.update myroads_net_time layer=3 col=cost val="length / speed * 60" .br # set backward costs .br v.db.update myroads_net_time layer=3 col=bcost val="length / speed * 60" .br .br # ... the 'start' and 'end' nodes have category number 1 and 2 .br .br # Shortest path: ID as first number, then cat1 and cat2 .br echo "1 1 2" | v.net.path myroads_net_time alayer=3 nlayer=2 out=mypath .br .br # Fastest path: ID as first number, then cat1 and cat2 .br echo "1 1 2" | v.net.path myroads_net_time alayer=3 nlayer=2 afcol=cost abcol=bcost out=mypath_time .br .DE \fR To display the result, run for example: \fC .DS .br g.region vect=myroads_net .br d.mon x0 .br d.vect myroads_net .br # show shortest path .br d.vect mypath col=red width=2 .br # show fastest path .br d.vect mypath_time col=blue width=2 .br .br # start and end point .br d.vect myroads_net icon=basic/triangle fcol=green size=12 layer=2 .br d.font font=Vera .br d.vect startend disp=cat type=point lsize=14 layer=2 .br .DE \fR .SH SEE ALSO \fId.path\fR, \fIv.net\fR, \fIv.net.alloc\fR, \fIv.net.iso\fR, \fIv.net.salesman\fR, \fIv.net.steiner\fR, \fIv.to.db\fR .SH AUTHOR Radim Blazek, ITC-Irst, Trento, Italy .br Documentation: Markus Neteler, Markus Metz .PP \fILast changed: $Date: 2013-05-23 22:01:55 +0200 (Thu, 23 May 2013) $\fR .PP Full index .PP © 2003-2014 GRASS Development Team