1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201
|
<h2>DESCRIPTION</h2>
<em>v.net.path</em> determines least costly, e.g. shortest or fastest
path(s) on a vector network.
<p>
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
<div class="code"><pre>
length / speed = 10 km / (100 km/h) = 0.1 h.
</pre></div>
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.
<p>
The input vector needs to be prepared with <code>v.net operation=connect</code>
in order to connect points representing center nodes to the network.
<p>Nodes and arcs can be closed using <code>cost = -1</code>.
<p>Least cost paths are written to the output vector map with an
attached attribute table.
<p>Nodes can be
<ul>
<li> piped into the program from file or from stdin, or</li>
<li> defined in the graphical user interface ("enter values interactively").</li>
</ul>
The syntax is as follows:
<div class="code"><pre>
id start_point_category end_point_category
</pre></div>
(Example: 1 1 2)
<p>
or
<div class="code"><pre>
id start_point_x start_point_y end_point_x end_point_y
</pre></div>
<p>
Points specified by category must be exactly on network nodes, and the
input vector map needs to be prepared with <code>v.net operation=connect</code>.
<p>
When specifying coordinates, the next network node to a given coordinate
pair is used.
<p>
The attribute table will contain the following attributes:
<ul>
<li><code>cat</code> - path unique category assigned by module</li>
<li><code>id</code> - path id (read from input)</li>
<li><code>fcat</code> - from point category</li>
<li><code>tcat</code> - to point category</li>
<li><code>sp</code> - result status:
<ul>
<li> 0 - OK, path found</li>
<li> 1 - node is not reachable</li>
<li> 2 - point of given category does not exist</li>
</ul></li>
<li><code>cost</code> - travelling costs (on the network, not to/from network)</li>
<li><code>fdist</code> - the distance from first point to the network</li>
<li><code>tdist</code> - the distance from the network to second point</li>
</ul>
<p>
Application of flag <b>-t</b> enables a turntable support.
This flag requires additional parameters <b>turn_layer</b> and <b>turn_cat_layer</b>
that are otherwise ignored.
The turntable allows
to model e.g. traffic code, where some turns may be prohibited.
This means that the input layer is expanded by
turntable with costs of every possible turn on any possible node
(intersection) in both directions.
Turntable can be created by
the <em><a href="v.net.html">v.net</a></em> module.
For more information about turns in the vector network analyses see
<a href="https://grasswiki.osgeo.org/wiki/Turns_in_the_vector_network_analysis">wiki page</a>.
<h2>NOTES</h2>
Nodes and arcs can be closed using <code>cost = -1</code>.
<p>If the cost columns <b>arc_column</b>, <b>arc_backward_column</b> and <b>node_column</b> are not
specified, the length of network segments is measured and
zero costs are assumed for nodes.
<p>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 <em>fastest path</em>,
the columns 'max_speed' and 'length' are required. The correct fastest
path can then be found by specifying <code>arc_column=length/max_speed</code>. If not yet
existing, the column containing the line length ("length") has to added to the
attributes table using <em><a href="v.to.db.html">v.to.db</a></em>.
<h2>EXAMPLE</h2>
Shortest (red) and fastest (blue) path between two digitized nodes (Spearfish):
<p>
<center>
<img src="vnetpath.png" alt="v.net.path example" border="1">
</center>
<div class="code"><pre>
# Spearfish
echo "1|601955.1|4916944.9|start
2|594385.6|4921565.2|end" | v.in.ascii in=- cat=1 x=2 y=3 out=startend col="cat integer, \
east double precision, north double precision, label varchar(6)"
v.db.select startend
g.copy vect=roads,myroads
# create lines map connecting points to network
v.net myroads points=startend out=myroads_net op=connect thresh=500 arc_layer=1 node_layer=2
# set up costs
# 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,bcost 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:
# set forward costs
v.db.update myroads_net_time layer=3 col=cost val="length / speed * 60"
# set backward costs
v.db.update myroads_net_time layer=3 col=bcost val="length / speed * 60"
# ... the 'start' and 'end' nodes have category number 1 and 2
# Shortest path: ID as first number, then cat1 and cat2
echo "1 1 2" | v.net.path myroads_net_time arc_layer=3 node_layer=2 out=mypath
# Fastest path: ID as first number, then cat1 and cat2
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
</pre></div>
To display the result, run for example:
<div class="code"><pre>
g.region vector=myroads_net
d.mon x0
d.vect myroads_net
# show shortest path
d.vect mypath col=red width=2
# show fastest path
d.vect mypath_time col=blue width=2
# start and end point
d.vect myroads_net icon=basic/triangle fcol=green size=12 layer=2
d.font font=Vera
d.vect startend disp=cat type=point lsize=14 layer=2
</pre></div>
<h2>SEE ALSO</h2>
<em>
<a href="d.path.html">d.path</a>,
<a href="v.net.html">v.net</a>,
<a href="v.net.alloc.html">v.net.alloc</a>,
<a href="v.net.iso.html">v.net.iso</a>,
<a href="v.net.salesman.html">v.net.salesman</a>,
<a href="v.net.steiner.html">v.net.steiner</a>,
<a href="v.to.db.html">v.to.db</a>
</em>
<h2>AUTHORS</h2>
Radim Blazek, ITC-Irst, Trento, Italy<br>
Documentation: Markus Neteler, Markus Metz
<h3>TURNS SUPPORT</h3>
The turns support was implemnented as part of GRASS GIS turns cost project at Czech Technical University in Prague, Czech Republic.
<p>
Implementation: Stepan Turek<br>
Documentation: Lukas Bocan, Eliska Kyzlikova, Viera Bejdova<br>
Mentor: Martin Landa
|