v.net.alloc.html 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. <h2>DESCRIPTION</h2>
  2. <em>v.net.alloc</em> allocates subnets for nearest centers
  3. (direction from center). center nodes must be opened (costs &gt;= 0).
  4. Costs of center nodes are used in the calculation.
  5. <p>
  6. Costs may be either line lengths, or attributes saved in a
  7. database table. These attribute values are taken as costs of whole
  8. segments, not as costs to traverse a length unit (e.g. meter) of the
  9. segment. For example, if the speed limit is 100 km / h, the cost to
  10. traverse a 10 km long road segment must be calculated as
  11. <br>
  12. length / speed = 10 km / (100 km/h) = 0.1 h.
  13. <br>
  14. Supported are cost assignments for both arcs and nodes,
  15. and also different costs for both directions of a vector line.
  16. For areas, costs will be calculated along boundary lines.
  17. <p>
  18. The input vector needs to be prepared with <em>v.net operation=connect</em>
  19. in order to connect points representing center nodes to the network.
  20. <p>
  21. Application of flag <b>-t</b> enables a turntable support.
  22. This flag requires additional parameters <b>tlayer</b> and <b>tuclayer</b>
  23. that are otherwise ignored.
  24. The turntable allows
  25. to model e.g. trafic code, where some turns may be prohibited.
  26. This means that the input layer is expanded by
  27. turntable with costs of every possible turn on any possible node
  28. (intersection) in both directions.
  29. Turntable can be created by
  30. the <em><a href="v.net.html">v.net</a></em> module.
  31. For more information about turns in the vector network analyses see
  32. <a href="http://grasswiki.osgeo.org/wiki/Turns_in_the_vector_network_analysis">wiki page</a>.
  33. <h2>NOTES</h2>
  34. Nodes and arcs can be closed using cost = -1.
  35. <p>
  36. Center nodes can also be assigned to vector nodes using
  37. <em><a href="wxGUI.vdigit.html">wxGUI vector digitizer</a></em>.
  38. <h2>EXAMPLES</h2>
  39. <p>1. Subnetwork allocation using distance:
  40. <p><img src="v_net_alloc.png" alt="v.net.alloc example using distance" border="1">
  41. <br>
  42. <p>2. Subnetwork allocation using traveling time:
  43. <p><img src="v_net_alloc_time.png" alt="v.net.alloc example using time" border="1">
  44. <br>
  45. <p>Example 1: <em>Calculating subnets for 3 center nodes using distances</em>
  46. <div class="code"><pre>
  47. # Spearfish
  48. # center nodes:
  49. echo "591235.5|4926306.62|1
  50. 596591.8|4917042.5|2
  51. 602722.9|4923544.2|3" | v.in.ascii in=- out=centernodes
  52. g.copy vect=roads,myroads
  53. # connect points to network
  54. v.net myroads points=centernodes out=myroads_net op=connect thresh=200
  55. # allocate, specifying range of center cats (easier to catch all):
  56. v.net.alloc myroads_net out=myroads_net_alloc ccats=1-100000 nlayer=2
  57. # report categories
  58. v.category myroads_net_alloc option=report
  59. </pre></div>
  60. To display the result, run for example:
  61. <div class="code"><pre>
  62. # show result
  63. g.region vect=myroads_net
  64. d.mon x0
  65. d.vect myroads_net layer=1
  66. # the result has to be selected by category number of the relevant node:
  67. d.vect myroads_net_alloc cat=1 col=red layer=1
  68. d.vect myroads_net_alloc cat=2 col=green layer=1
  69. d.vect myroads_net_alloc cat=3 col=yellow layer=1
  70. # center nodes
  71. d.vect myroads_net col=red icon=basic/triangle fcol=green size=12 layer=2
  72. </pre></div>
  73. <p>Example 2: <em>Calculating subnets for 3 center nodes using traveling time</em><br>
  74. <div class="code"><pre>
  75. # Spearfish
  76. # center nodes:
  77. echo "591235.5|4926306.62|1
  78. 596591.8|4917042.5|2
  79. 602722.9|4923544.2|3" | v.in.ascii in=- out=centernodes
  80. g.copy vect=roads,myroads
  81. # create lines map connecting points to network
  82. v.net myroads points=centernodes out=myroads_net op=connect thresh=500 alayer=1 nlayer=2
  83. # set up costs
  84. # create unique categories for each road in layer 3
  85. v.category in=myroads_net out=myroads_net_time opt=add cat=1 layer=3 type=line
  86. # add new table for layer 3
  87. 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"
  88. # copy road type to layer 3
  89. v.to.db myroads_net_time layer=3 qlayer=1 opt=query qcolumn=label columns=label
  90. # upload road length in miles
  91. v.to.db myroads_net_time layer=3 type=line option=length col=length unit=miles
  92. # set speed limits in miles / hour
  93. v.db.update myroads_net_time layer=3 col=speed val="5.0"
  94. v.db.update myroads_net_time layer=3 col=speed val="75.0" where="label='interstate'"
  95. v.db.update myroads_net_time layer=3 col=speed val="75.0" where="label='primary highway, hard surface'"
  96. v.db.update myroads_net_time layer=3 col=speed val="50.0" where="label='secondary highway, hard surface'"
  97. v.db.update myroads_net_time layer=3 col=speed val="25.0" where="label='light-duty road, improved surface'"
  98. v.db.update myroads_net_time layer=3 col=speed val="5.0" where="label='unimproved road'"
  99. # define traveling costs as traveling time in minutes:
  100. # set forward costs
  101. v.db.update myroads_net_time layer=3 col=cost val="length / speed * 60"
  102. # set backward costs
  103. v.db.update myroads_net_time layer=3 col=bcost val="length / speed * 60"
  104. # subnetwork allocation with fastest paths
  105. v.net.alloc in=myroads_net_time alayer=3 nlayer=2 afcol=cost abcol=bcost out=myroads_net_alloc_time ccats=1-3
  106. </pre></div>
  107. To display the result, run for example:
  108. <div class="code"><pre>
  109. # show result
  110. g.region vect=myroads_net
  111. d.mon x0
  112. d.vect myroads_net type=line layer=1
  113. # the result has to be selected by category number of the relevant node:
  114. d.vect myroads_net_alloc_time cat=1 col=red layer=1
  115. d.vect myroads_net_alloc_time cat=2 col=green layer=1
  116. d.vect myroads_net_alloc_time cat=3 col=yellow layer=1
  117. # center nodes
  118. d.vect myroads_net_time col=red icon=basic/triangle fcol=green size=12 type=point layer=2
  119. </pre></div>
  120. <h2>SEE ALSO</h2>
  121. <em><a href="d.path.html">d.path</a></em>,
  122. <em><a href="v.net.html">v.net</a></em>,
  123. <em><a href="v.net.iso.html">v.net.iso</a></em>,
  124. <em><a href="v.net.path.html">v.net.path</a></em>,
  125. <em><a href="v.net.steiner.html">v.net.steiner</a></em>,
  126. <em><a href="v.net.salesman.html">v.net.salesman</a></em>
  127. <h2>AUTHOR</h2>
  128. Radim Blazek, ITC-Irst, Trento, Italy<br>
  129. Documentation: Markus Neteler, Markus Metz
  130. <h3>TURNS SUPPORT</h3>
  131. The turns support was implemnented as part of GRASS GIS turns cost project at Czech Technical University in Prague, Czech Republic.
  132. Eliska Kyzlikova, Stepan Turek, Lukas Bocan and Viera Bejdova participated at the project.
  133. Implementation: Stepan Turek
  134. Documentation: Lukas Bocan
  135. Mentor: Martin Landa
  136. <p><i>Last changed: $Date$</i>