r.drain.html 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. <h2>DESCRIPTION</h2>
  2. <em>r.drain</em> traces a flow through a least-cost path in an
  3. elevation model or cost surface. For cost surfaces, a movement
  4. direction map must be specified with the
  5. <b>direction</b> option and the <b>-d</b> flag to trace a flow path following
  6. the given directions. Such a movement direction map can be generated with
  7. <em><a href="r.walk.html">r.walk</a></em>,
  8. <em><a href="r.cost.html">r.cost</a></em>,
  9. <em><a href="r.slope.aspect.html">r.slope.aspect</a></em> or
  10. <em><a href="r.watershed.html">r.watershed</a></em>.
  11. <p>
  12. The <b>output</b> raster map will show one or more least-cost paths
  13. between each user-provided location(s) and the minima (low category
  14. values) in the raster <b>input</b> map. If the <b>-d</b> flag is used
  15. the output least-cost paths will be found using the direction raster
  16. map. By default, the <b>output</b> will be an integer CELL map with
  17. category 1 along the least cost path, and null cells elsewhere.
  18. <p>With the <b>-c</b> (<em>copy</em>) flag, the input raster map cell values are
  19. copied verbatim along the path. With the <b>-a</b> (<em>accumulate</em>)
  20. flag, the accumulated cell value from the starting point up to the current
  21. cell is written on output. With either the <b>-c</b> or the <b>-a</b> flags, the
  22. <b>output</b> map is created with the same cell type as
  23. the <b>input</b> raster map (integer, float or double). With
  24. the <b>-n</b> (<em>number</em>) flag, the cells are numbered
  25. consecutively from the starting point to the final point.
  26. The <b>-c</b>, <b>-a</b>, and <b>-n</b> flags are mutually
  27. incompatible.
  28. <p>For an elevation surface, the path is calculated by choosing the
  29. steeper "slope" between adjacent cells. The slope calculation
  30. accurately acounts for the variable scale in lat-lon projections. For
  31. a cost surface, the path is calculated by following the movement
  32. direction surface back to the start point given
  33. in <em><a href="r.walk.html">r.walk</a></em> or
  34. <em><a href="r.cost.html">r.cost</a></em>. The path search stops
  35. as soon as a region border or a neighboring NULL cell is encountered,
  36. because in these cases the direction can not be determined (the path
  37. could continue outside the current region).
  38. <p>The <b>start_coordinates</b> parameter consists of map E and N grid coordinates of
  39. a starting point. Each x,y pair is the easting and northing (respectively) of
  40. a starting point from which a least-cost corridor will be developed.
  41. The <b>start_points</b> parameter can take multiple vector maps containing
  42. additional starting points.
  43. Up to 1024 starting points can be input from a combination of the
  44. <b>start_coordinates</b> and <b>start_points</b> parameters.
  45. <h2>NOTES</h2>
  46. If no direction input map is given, <em>r.drain</em> currently finds
  47. only the lowest point (the cell having the smallest category value) in
  48. the input file that can be reached through directly adjacent cells
  49. that are less than or equal in value to the cell reached immediately
  50. prior to it; therefore, it will not necessarily reach the lowest point
  51. in the input file. It currently finds <em>pits</em> in the data,
  52. rather than the lowest point in the entire input
  53. map. The <em><a href="r.fill.dir.html">r.fill.dir</a></em>,
  54. <em><a href="r.terraflow.html">r.terraflow</a></em>,
  55. and <em><a href="r.basins.fill.html">r.basins.fill</a></em> modules
  56. can be used to fill in subbasins prior to processing
  57. with <em>r.drain</em>.
  58. <p>
  59. <em>r.drain</em> will not give sane results at the region boundary. On outer rows
  60. and columns bordering the edge of the region, the flow direction is always directly out
  61. of the map. In this case, the user could try adjusting the region extents slightly with
  62. <em>g.region</em> to allow additional outlet paths for <em>r.drain</em>.
  63. <h2>EXAMPLES</h2>
  64. Consider the following example:
  65. <div class="code"><pre>
  66. Input: Output:
  67. ELEVATION SURFACE LEAST COST PATH
  68. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  69. . 19. 20. 18. 19. 16. 15. 15. . . . . . . . .
  70. . . --- . . . . . . . . . . . . . . . . . . . . . . . . .
  71. . 20| 19| 17. 16. 17. 16. 16. . . 1 . 1 . 1 . . . .
  72. . . --- . . . . . . . . . . . . . . . . . . . . . . . . .
  73. . 18. 18. 24. 18. 15. 12. 11. . . . . . 1 . . .
  74. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  75. . 22. 16. 16. 18. 10. 10. 10. . . . . . 1 . . .
  76. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  77. . 17. 15. 15. 15. 10. 8 . 8 . . . . . . . 1 . .
  78. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  79. . 24. 16. 8 . 7 . 8 . 0 . 12. . . . . . . 1 . .
  80. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  81. . 17. 9 . 8 . 7 . 8 . 6 . 12. . . . . . . . .
  82. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  83. </pre></div>
  84. <p>
  85. The user-provided starting location in the above example is
  86. the boxed <b>19</b> in the left-hand map. The path in the output
  87. shows the least-cost corridor for moving from the starting
  88. box to the lowest (smallest) possible point. This is the path a raindrop
  89. would take in this landscape.
  90. <p>
  91. With the <b>-c</b> <em>(copy)</em> flag, you get the following result:
  92. <div class="code"><pre>
  93. Input: Output:
  94. ELEVATION SURFACE LEAST COST PATH
  95. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  96. . 19. 20. 18. 19. 16. 15. 15. . . . . . . . .
  97. . . --- . . . . . . . . . . . . . . . . . . . . . . . . .
  98. . 20| 19| 17. 16. 17. 16. 16. . . 19. 17. 16. . . .
  99. . . --- . . . . . . . . . . . . . . . . . . . . . . . . .
  100. . 18. 18. 24. 18. 15. 12. 11. . . . . . 15. . .
  101. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  102. . 22. 16. 16. 18. 10. 10. 10. . . . . . 10. . .
  103. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  104. . 17. 15. 15. 15. 10. 8 . 8 . . . . . . . 8 . .
  105. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  106. . 24. 16. 8 . 7 . 8 . 0 .12 . . . . . . . 0 . .
  107. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  108. . 17. 9 . 8 . 7 . 8 . 6 .12 . . . . . . . . .
  109. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  110. Note that the last <em>0</em> will not be put in the null values map.
  111. </pre></div>
  112. <p>
  113. With the <b>-a</b> <em>(accumulate)</em> flag, you get the following result:
  114. <div class="code"><pre>
  115. Input: Output:
  116. ELEVATION SURFACE LEAST COST PATH
  117. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  118. . 19. 20. 18. 19. 16. 15. 15. . . . . . . . .
  119. . . --- . . . . . . . . . . . . . . . . . . . . . . . . .
  120. . 20| 19| 17. 16. 17. 16. 16. . . 19. 36. 52. . . .
  121. . . --- . . . . . . . . . . . . . . . . . . . . . . . . .
  122. . 18. 18. 24. 18. 15. 12. 11. . . . . . 67. . .
  123. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  124. . 22. 16. 16. 18. 10. 10. 10. . . . . . 77. . .
  125. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  126. . 17. 15. 15. 15. 10. 8 . 8 . . . . . . . 85. .
  127. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  128. . 24. 16. 8 . 7 . 8 . 0 .12 . . . . . . . 85. .
  129. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  130. . 17. 9 . 8 . 7 . 8 . 6 .12 . . . . . . . . .
  131. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  132. </pre></div>
  133. <p>
  134. With the <b>-n</b> <em>(number)</em> flag, you get the following result:
  135. <div class="code"><pre>
  136. Input: Output:
  137. ELEVATION SURFACE LEAST COST PATH
  138. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  139. . 19. 20. 18. 19. 16. 15. 15. . . . . . . . .
  140. . . --- . . . . . . . . . . . . . . . . . . . . . . . . .
  141. . 20| 19| 17. 16. 17. 16. 16. . . 1 . 2 . 3 . . . .
  142. . . --- . . . . . . . . . . . . . . . . . . . . . . . . .
  143. . 18. 18. 24. 18. 15. 12. 11. . . . . . 4 . . .
  144. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  145. . 22. 16. 16. 18. 10. 10. 10. . . . . . 5 . . .
  146. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  147. . 17. 15. 15. 15. 10. 8 . 8 . . . . . . . 6 . .
  148. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  149. . 24. 16. 8 . 7 . 8 . 0 .12 . . . . . . . 7 . .
  150. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  151. . 17. 9 . 8 . 7 . 8 . 6 .12 . . . . . . . . .
  152. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  153. </pre></div>
  154. With the <b>-d</b> <em>(direction)</em> flag, the direction raster is used
  155. for the input, rather than the elevation surface. The output is then created
  156. according to one of the <b>-can</b> flags.
  157. <div class="code"><pre>
  158. The directions are recorded as degrees CCW from East:
  159. 112.5 67.5 i.e. a cell with the value 135
  160. 157.5 135 90 45 22.5 means the next cell is to the North-West
  161. 180 x 0
  162. 202.5 225 270 315 337.5
  163. 247.5 292.5
  164. </pre></div>
  165. <p>
  166. <h2>KNOWN ISSUES</h2>
  167. <p>Sometimes, when the differences among integer cell category values in the
  168. <em><a href="r.cost.html">r.cost</a></em> cumulative cost surface output are
  169. small, this cumulative cost output cannot accurately be used as input to
  170. <em>r.drain</em> (<em>r.drain</em> will output bad results).
  171. This problem can be circumvented by making the differences
  172. between cell category values in the cumulative cost output bigger. It
  173. is recommended that if the output from <em>r.cost</em> is to be used
  174. as input to <em>r.drain</em>, the user multiply the <em>r.cost</em>
  175. input cost surface map by the value of the map's cell resolution,
  176. before running <em>r.cost</em>. This can be done using
  177. <em><a href="r.mapcalc.html">r.mapcalc</a></em>. The map resolution can be
  178. found using <em><a href="g.region.html">g.region</a></em>.
  179. This problem doesn't arise with floating point maps.
  180. <h2>SEE ALSO</h2>
  181. <em>
  182. <a href="g.region.html">g.region</a>,
  183. <a href="r.cost.html">r.cost</a>,
  184. <a href="r.fill.dir.html">r.fill.dir</a>,
  185. <a href="r.basins.fill.html">r.basins.fill</a>,
  186. <a href="r.terraflow.html">r.terraflow</a>,
  187. <a href="r.mapcalc.html">r.mapcalc</a>,
  188. <a href="r.walk.html">r.walk</a>
  189. </em>
  190. <h2>AUTHORS</h2>
  191. Completely rewritten by Roger S. Miller, 2001<br>
  192. July 2004 at WebValley 2004, error checking and vector points added by
  193. Matteo Franchi (Liceo Leonardo Da Vinci, Trento) and
  194. Roberto Flor (ITC-irst, Trento, Italy)
  195. <p>
  196. <i>Last changed: $Date$</i>