| 1 |
<h2>DESCRIPTION</h2> |
| 2 |
|
| 3 |
<em>v.net.alloc</em> allocates subnets for nearest centers. Center |
| 4 |
nodes must be opened (costs >= 0). Costs of center nodes are used in |
| 5 |
the calculation. |
| 6 |
<p> |
| 7 |
Costs may be either line lengths, or attributes saved in a |
| 8 |
database table. These attribute values are taken as costs of whole |
| 9 |
segments, not as costs to traverse a length unit (e.g. meter) of the |
| 10 |
segment. For example, if the speed limit is 100 km / h, the cost to |
| 11 |
traverse a 10 km long road segment must be calculated as |
| 12 |
<br> |
| 13 |
length / speed = 10 km / (100 km/h) = 0.1 h. |
| 14 |
<br> |
| 15 |
Supported are cost assignments for both arcs and nodes, |
| 16 |
and also different costs for both directions of a vector line. |
| 17 |
For areas, costs will be calculated along boundary lines. |
| 18 |
<p> |
| 19 |
The input vector needs to be prepared with <em>v.net operation=connect</em> |
| 20 |
in order to connect points representing center nodes to the network. |
| 21 |
<p> |
| 22 |
The nearest center can be determined using either costs from the |
| 23 |
nearest center or costs to the nearest center with option |
| 24 |
<b>method</b>. See example below. |
| 25 |
<p> |
| 26 |
By default, the category value of the nearest center is used as |
| 27 |
category value for output lines. With the <b>-u</b> flag, output lines |
| 28 |
become unique categories and an attribute table is created with the |
| 29 |
fields <em>cat, ocat, center</em>. The <em>ocat</em> field holds the |
| 30 |
original line category in <b>arc_layer</b> and the <em>center</em> |
| 31 |
field holds the center category in <b>node_layer</b>. Additionally, |
| 32 |
original line categories are copied from the input <b>arc_layer</b> to |
| 33 |
layer 2 in the output, together with any attribute table. |
| 34 |
<p> |
| 35 |
Application of flag <b>-t</b> enables a turntable support. This flag |
| 36 |
requires additional parameters <b>turn_layer</b> and |
| 37 |
<b>turn_cat_layer</b> that are otherwise ignored. The turntable allows |
| 38 |
to model e.g. traffic code, where some turns may be prohibited. This |
| 39 |
means that the input layer is expanded by turntable with costs of every |
| 40 |
possible turn on any possible node (intersection) in both directions. |
| 41 |
Turntable can be created by the <em><a href="v.net.html">v.net</a></em> |
| 42 |
module. For more information about turns in the vector network analyses |
| 43 |
see |
| 44 |
<a href="https://grasswiki.osgeo.org/wiki/Turns_in_the_vector_network_analysis">wiki page</a>. |
| 45 |
|
| 46 |
<h2>NOTES</h2> |
| 47 |
|
| 48 |
Nodes and arcs can be closed using cost = -1. |
| 49 |
<p> |
| 50 |
Center nodes can also be assigned to vector nodes using |
| 51 |
<em><a href="wxGUI.vdigit.html">wxGUI vector digitizer</a></em>. |
| 52 |
|
| 53 |
<h2>EXAMPLES</h2> |
| 54 |
|
| 55 |
<p>1. Subnetwork allocation using distance: |
| 56 |
<p><img src="v_net_alloc.png" alt="v.net.alloc example using distance" border="1"> |
| 57 |
<br> |
| 58 |
<p>2. Subnetwork allocation using traveling time: |
| 59 |
<p><img src="v_net_alloc_time.png" alt="v.net.alloc example using time" border="1"> |
| 60 |
<br> |
| 61 |
|
| 62 |
<p>Example 1: <em>Calculating subnets for 3 center nodes using distances</em> |
| 63 |
<div class="code"><pre> |
| 64 |
# Spearfish |
| 65 |
|
| 66 |
# center nodes: |
| 67 |
echo "591235.5|4926306.62|1 |
| 68 |
596591.8|4917042.5|2 |
| 69 |
602722.9|4923544.2|3" | v.in.ascii in=- out=centernodes |
| 70 |
|
| 71 |
g.copy vect=roads,myroads |
| 72 |
|
| 73 |
# connect points to network |
| 74 |
v.net myroads points=centernodes out=myroads_net op=connect thresh=200 |
| 75 |
|
| 76 |
# allocate, specifying range of center cats (easier to catch all): |
| 77 |
v.net.alloc myroads_net out=myroads_net_alloc center_cats=1-100000 node_layer=2 |
| 78 |
|
| 79 |
# report categories |
| 80 |
v.category myroads_net_alloc option=report |
| 81 |
</pre></div> |
| 82 |
|
| 83 |
To display the result, run for example: |
| 84 |
|
| 85 |
<div class="code"><pre> |
| 86 |
# show result |
| 87 |
g.region vector=myroads_net |
| 88 |
d.mon x0 |
| 89 |
d.vect myroads_net layer=1 |
| 90 |
|
| 91 |
# the result has to be selected by category number of the relevant node: |
| 92 |
d.vect myroads_net_alloc cat=1 col=red layer=1 |
| 93 |
d.vect myroads_net_alloc cat=2 col=green layer=1 |
| 94 |
d.vect myroads_net_alloc cat=3 col=yellow layer=1 |
| 95 |
|
| 96 |
# center nodes |
| 97 |
d.vect myroads_net col=red icon=basic/triangle fcol=green size=12 layer=2 |
| 98 |
</pre></div> |
| 99 |
|
| 100 |
<p>Example 2: <em>Calculating subnets for 3 center nodes using traveling time</em><br> |
| 101 |
|
| 102 |
<div class="code"><pre> |
| 103 |
# Spearfish |
| 104 |
|
| 105 |
# center nodes: |
| 106 |
echo "591235.5|4926306.62|1 |
| 107 |
596591.8|4917042.5|2 |
| 108 |
602722.9|4923544.2|3" | v.in.ascii in=- out=centernodes |
| 109 |
|
| 110 |
g.copy vect=roads,myroads |
| 111 |
|
| 112 |
# create lines map connecting points to network |
| 113 |
v.net myroads points=centernodes out=myroads_net op=connect thresh=500 arc_layer=1 node_layer=2 |
| 114 |
|
| 115 |
# set up costs |
| 116 |
|
| 117 |
# create unique categories for each road in layer 3 |
| 118 |
v.category in=myroads_net out=myroads_net_time opt=add cat=1 layer=3 type=line |
| 119 |
|
| 120 |
# add new table for layer 3 |
| 121 |
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" |
| 122 |
|
| 123 |
# copy road type to layer 3 |
| 124 |
v.to.db myroads_net_time layer=3 qlayer=1 opt=query qcolumn=label columns=label |
| 125 |
|
| 126 |
# upload road length in miles |
| 127 |
v.to.db myroads_net_time layer=3 type=line option=length col=length unit=miles |
| 128 |
|
| 129 |
# set speed limits in miles / hour |
| 130 |
v.db.update myroads_net_time layer=3 col=speed val="5.0" |
| 131 |
v.db.update myroads_net_time layer=3 col=speed val="75.0" where="label='interstate'" |
| 132 |
v.db.update myroads_net_time layer=3 col=speed val="75.0" where="label='primary highway, hard surface'" |
| 133 |
v.db.update myroads_net_time layer=3 col=speed val="50.0" where="label='secondary highway, hard surface'" |
| 134 |
v.db.update myroads_net_time layer=3 col=speed val="25.0" where="label='light-duty road, improved surface'" |
| 135 |
v.db.update myroads_net_time layer=3 col=speed val="5.0" where="label='unimproved road'" |
| 136 |
|
| 137 |
# define traveling costs as traveling time in minutes: |
| 138 |
|
| 139 |
# set forward costs |
| 140 |
v.db.update myroads_net_time layer=3 col=cost val="length / speed * 60" |
| 141 |
# set backward costs |
| 142 |
v.db.update myroads_net_time layer=3 col=bcost val="length / speed * 60" |
| 143 |
|
| 144 |
# subnetwork allocation with fastest paths |
| 145 |
v.net.alloc in=myroads_net_time arc_layer=3 node_layer=2 arc_column=cost arc_backward_column=bcost out=myroads_net_alloc_time center_cats=1-3 |
| 146 |
</pre></div> |
| 147 |
|
| 148 |
To display the result, run for example: |
| 149 |
|
| 150 |
<div class="code"><pre> |
| 151 |
# show result |
| 152 |
g.region vector=myroads_net |
| 153 |
d.mon x0 |
| 154 |
d.vect myroads_net type=line layer=1 |
| 155 |
|
| 156 |
# the result has to be selected by category number of the relevant node: |
| 157 |
d.vect myroads_net_alloc_time cat=1 col=red layer=1 |
| 158 |
d.vect myroads_net_alloc_time cat=2 col=green layer=1 |
| 159 |
d.vect myroads_net_alloc_time cat=3 col=yellow layer=1 |
| 160 |
|
| 161 |
# center nodes |
| 162 |
d.vect myroads_net_time col=red icon=basic/triangle fcol=green size=12 type=point layer=2 |
| 163 |
</pre></div> |
| 164 |
|
| 165 |
<p>Example 3: <em>Differences between costs from centers and costs to centers</em><br> |
| 166 |
|
| 167 |
Each lane of the two-lane road is a one-way road. |
| 168 |
<p>1. Subnetwork allocation from centers: |
| 169 |
<p><img src="v_net_alloc_from_centers.png" alt="v.net.alloc example from centers" border="1"> |
| 170 |
<br> |
| 171 |
A center reaches any point following the one-way lanes. |
| 172 |
<p>2. Subnetwork allocation to centers: |
| 173 |
<p><img src="v_net_alloc_to_centers.png" alt="v.net.alloc example to centers" border="1"> |
| 174 |
<br> |
| 175 |
Any node reaches reaches the nearest center following the one-way lanes. |
| 176 |
<p> |
| 177 |
In case of an accident, the ambulance should come from the nearest |
| 178 |
'from' hospital and go to the nearest 'to' hospital. |
| 179 |
|
| 180 |
<div class="code"><pre> |
| 181 |
# North Carolina |
| 182 |
|
| 183 |
# center nodes are hospitals: |
| 184 |
# connect hospitals to streets as layer 2 |
| 185 |
v.net input=streets_wake points=hospitals output=streets_hospitals operation=connect thresh=400 arc_layer=1 node_layer=2 |
| 186 |
v.to.db map=streets_hospitals layer=1 type=line option=cat columns=cat |
| 187 |
|
| 188 |
# close oneway roads |
| 189 |
v.db.update map=streets_hospitals column=TF_COST value=-1 where="ONE_WAY = 'FT'" |
| 190 |
v.db.update map=streets_hospitals column=FT_COST value=-1 where="ONE_WAY = 'TF'" |
| 191 |
|
| 192 |
# add costs to newly created lines |
| 193 |
v.db.update map=streets_hospitals column=TF_COST value=0 where="cat > 49746" |
| 194 |
v.db.update map=streets_hospitals column=FT_COST value=0 where="cat > 49746" |
| 195 |
|
| 196 |
# from centers |
| 197 |
v.net.alloc in=streets_hospitals out=streets_hospitals_alloc_from center_cats=1-10000 arc_column=FT_COST arc_backward_column=TF_COST |
| 198 |
|
| 199 |
# to centers |
| 200 |
v.net.alloc in=streets_hospitals out=streets_hospitals_alloc_to method=to center_cats=1-10000 arc_column=FT_COST arc_backward_column=TF_COST |
| 201 |
</pre></div> |
| 202 |
|
| 203 |
<h2>SEE ALSO</h2> |
| 204 |
|
| 205 |
<em> |
| 206 |
<a href="d.path.html">d.path</a>, |
| 207 |
<a href="v.net.html">v.net</a>, |
| 208 |
<a href="v.net.iso.html">v.net.iso</a>, |
| 209 |
<a href="v.net.path.html">v.net.path</a>, |
| 210 |
<a href="v.net.steiner.html">v.net.steiner</a>, |
| 211 |
<a href="v.net.salesman.html">v.net.salesman</a> |
| 212 |
</em> |
| 213 |
|
| 214 |
<h2>AUTHORS</h2> |
| 215 |
|
| 216 |
Radim Blazek, ITC-Irst, Trento, Italy<br> |
| 217 |
Documentation: Markus Neteler, Markus Metz |
| 218 |
|
| 219 |
<h3>TURNS SUPPORT</h3> |
| 220 |
|
| 221 |
The turns support was implemnented as part of GRASS GIS turns cost project at Czech Technical University in Prague, Czech Republic. |
| 222 |
Eliska Kyzlikova, Stepan Turek, Lukas Bocan and Viera Bejdova participated at the project. |
| 223 |
|
| 224 |
Implementation: Stepan Turek |
| 225 |
Documentation: Lukas Bocan |
| 226 |
Mentor: Martin Landa |