r.terraflow.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. <h2>DESCRIPTION</h2>
  2. <p><em>r.terraflow</em> takes as input a raster digital elevation
  3. model (DEM) and computes the flow direction raster and the flow
  4. accumulation raster, as well as the flooded elevation raster,
  5. sink-watershed raster (partition into watersheds around sinks) and TCI
  6. (topographic convergence index) raster maps.
  7. <p><em>r.terraflow</em> computes these rasters using well-known
  8. approaches, with the difference that its emphasis is on the
  9. computational complexity of the algorithms, rather than on modeling
  10. realistic flow. <em>r.terraflow</em> emerged from the necessity of
  11. having scalable software able to process efficiently very large
  12. terrains. It is based on theoretically optimal algorithms developed
  13. in the framework of I/O-efficient algorithms. <em>r.terraflow</em>
  14. was designed and optimized especially for massive grids and is able to
  15. process terrains which were impractical with similar functions
  16. existing in other GIS systems.
  17. <p>Flow directions are computed using either the MFD (Multiple Flow
  18. Direction) model or the SFD (Single Flow Direction, or D8) model,
  19. illustrated below. Both methods compute downslope flow directions by
  20. inspecting the 3-by-3 window around the current cell. The SFD method
  21. assigns a unique flow direction towards the steepest downslope
  22. neighbor. The MFD method assigns multiple flow directions towards all
  23. downslope neighbors.
  24. <p><table width="80%" align=center>
  25. <tr>
  26. <th><img src="rterraflow_dir2.png" alt="r.terraflow SFD"></th>
  27. <th><img src="rterraflow_dir3.png" alt="r.terraflow MFD"></th>
  28. </tr>
  29. <tr>
  30. <th>Flow direction to steepest<br> downslope neighbor (SFD).</th>
  31. <th>Flow direction to all<br> downslope neighbors (MFD).</th>
  32. </tr>
  33. </table>
  34. <p>The SFD and the MFD method cannot compute flow directions for
  35. cells which have the same height as all their neighbors (flat areas)
  36. or cells which do not have downslope neighbors (one-cell pits).
  37. <ul>
  38. <li>On plateaus (flat areas that spill out) <em>r.terraflow</em>
  39. routes flow so that globally the flow goes towards the spill cells of
  40. the plateaus.
  41. <li>On sinks (flat areas that do not spill out, including one-cell
  42. pits) <em>r.terraflow</em> assigns flow by flooding the terrain until
  43. all the sinks are filled and assigning flow directions on the filled
  44. terrain.
  45. </ul>
  46. <p>In order to flood the terrain, <em>r.terraflow</em> identifies all
  47. sinks and partitions the terrain into sink-watersheds (a
  48. sink-watershed contains all the cells that flow into that sink),
  49. builds a graph representing the adjacency information of the
  50. sink-watersheds, and uses this sink-watershed graph to merge
  51. watersheds into each other along their lowest common boundary until
  52. all watersheds have a flow path outside the terrain. Flooding produces
  53. a sink-less terrain in which every cell has a downslope flow path
  54. leading outside the terrain and therefore every cell in the terrain
  55. can be assigned SFD/MFD flow directions as above.
  56. <p>Once flow directions are computed for every cell in the terrain,
  57. <em>r.terraflow</em> computes flow accumulation by routing water using
  58. the flow directions and keeping track of how much water flows through
  59. each cell.
  60. <p>If flow accumulation of a cell is larger than the value given by the
  61. <b>d8cut</b> option, then
  62. the flow of this cell is routed to its neighbors using the SFD (D8)
  63. model. This option affects only the flow accumulation raster and is
  64. meaningful only for MFD flow (i.e. if the <b>-s</b> flag is not used); If
  65. this option is used for SFD flow it is ignored. The default value of
  66. <b>d8cut</b> is <i>infinity</i>.
  67. <p><em>r.terraflow</em> also computes the <b>tci</b> raster (topographic convergence
  68. index, defined as the logarithm of the ratio of flow accumulation and
  69. local slope).
  70. <p>For more details on the algorithms see [1,2,3] below.
  71. <h2>NOTES</h2>
  72. One of the techniques used by <em>r.terraflow</em> is the
  73. space-time trade-off. In particular, in order to avoid searches, which
  74. are I/O-expensive, <em>r.terraflow</em> computes and works with an
  75. augmented elevation raster in which each cell stores relevant
  76. information about its 8 neighbors, in total up to 80B per cell. As a
  77. result <em>r.terraflow</em> works with intermediate temporary files
  78. that may be up to 80N bytes, where N is the number of cells (rows x
  79. columns) in the elevation raster (more precisely, 80K bytes, where K
  80. is the number of valid (not no-data) cells in the input elevation
  81. raster).
  82. <p>All these intermediate temporary files are stored in the path specified
  83. by the <b>directory</b> option. Note: <b>directory</b> must contain
  84. enough free disk space in order to store up to 2 x 80N bytes.
  85. <p>The <b>memory</b> option can be used to set the maximum amount of main
  86. memory (RAM) the module will use during processing. In practice its
  87. <i>value</i> should be an underestimate of the amount of available
  88. (free) main memory on the machine. <em>r.terraflow</em> will use at
  89. all times at most this much memory, and the virtual memory system
  90. (swap space) will never be used. The default value is 300 MB.
  91. <p>The <b>stats</b> option defines the name of the file that contains the
  92. statistics (stats) of the run.
  93. <p><em>r.terraflow</em> has a limit on the number of rows and columns
  94. (max 32,767 each).
  95. <p>The internal type used by <em>r.terraflow</em> to store elevations
  96. can be defined at compile-time. By default, <em>r.terraflow</em> is
  97. compiled to store elevations internally as floats. Other versions can be
  98. created by the user if needed.
  99. <p>Hints concerning compilation with storage of elevations internally as
  100. shorts: such a version uses less space (up to 60B per cell, up
  101. to 60N intermediate file) and therefore is more space and time
  102. efficient. <em>r.terraflow</em> is intended for use with floating
  103. point raster data (FCELL), and <em>r.terraflow (short)</em> with integer
  104. raster data (CELL) in which the maximum elevation does not exceed the
  105. value of a short SHRT_MAX=32767 (this is not a constraint for any
  106. terrain data of the Earth, if elevation is stored in meters).
  107. Both <em>r.terraflow</em> and <em>r.terraflow (short)</em> work with
  108. input elevation rasters which can be either integer, floating point or
  109. double (CELL, FCELL, DCELL). If the input raster contains a value that
  110. exceeds the allowed internal range (short for
  111. <em>r.terraflow (short)</em>, float for <em>r.terraflow</em>), the
  112. program exits with a warning message. Otherwise, if all values in the
  113. input elevation raster are in range, they will be converted
  114. (truncated) to the internal elevation type (short for
  115. <em>r.terraflow (short)</em>, float for <em>r.terraflow</em>). In this
  116. case precision may be lost and artificial flat areas may be created.
  117. For instance, if <em>r.terraflow (short)</em> is used with floating
  118. point raster data (FCELL or DCELL), the values of the elevation will
  119. be truncated as shorts. This may create artificial flat areas, and the
  120. output of <em>r.terraflow (short)</em> may be less realistic than those
  121. of <em>r.terraflow</em> on floating point raster data.
  122. The outputs of <em>r.terraflow (short)</em> and <em>r.terraflow</em> are
  123. identical for integer raster data (CELL maps).
  124. <h2>EXAMPLES</h2>
  125. Example for small area in North Carolina sample dataset to calculate flow accumulation:
  126. <div class="code"><pre>
  127. g.region raster=elev_lid792_1m
  128. r.terraflow elevation=elev_lid792_1m accumulation=elev_lid792_1m_accumulation
  129. </pre></div>
  130. <div align="center" style="margin: 10px">
  131. <img src="rterraflow_accumulation.png" border=0><br>
  132. <i>Flow accumulation</i>
  133. </div>
  134. <!--
  135. image generated using
  136. d.mon wx0
  137. d.rast elev_lid792_1m
  138. d.rast elev_lid792_1m_accumulation
  139. save image to files
  140. crop the background using Gimp or ImageMagic
  141. mogrify -trim *.png
  142. some bounding box problems noticed when opening mogrify result in Gimp
  143. -->
  144. <p>
  145. Spearfish sample data set:
  146. <div class="code"><pre>
  147. g.region raster=elevation.10m -p
  148. r.terraflow elev=elevation.10m filled=elevation10m.filled \
  149. dir=elevation10m.mfdir swatershed=elevation10m.watershed \
  150. accumulation=elevation10m.accu tci=elevation10m.tci
  151. </pre></div>
  152. <div class="code"><pre>
  153. g.region raster=elevation.10m -p
  154. r.terraflow elev=elevation.10m filled=elevation10m.filled \
  155. dir=elevation10m.mfdir swatershed=elevation10m.watershed \
  156. accumulation=elevation10m.accu tci=elevation10m.tci d8cut=500 memory=800 \
  157. stats=elevation10mstats.txt
  158. </pre></div>
  159. <h2>REFERENCES</h2>
  160. <ol>
  161. <li> The <a href="http://www.cs.duke.edu/geo*/terraflow/">TerraFlow</a> project at Duke University
  162. <li><A NAME="arge:drainage"
  163. HREF="http://www.cs.duke.edu/geo*/terraflow/papers/alenex00_drainage.ps.gz">
  164. I/O-efficient algorithms for problems on grid-based
  165. terrains</a>. Lars Arge, Laura Toma, and Jeffrey S. Vitter. In
  166. <em>Proc. Workshop on Algorithm Engineering and Experimentation</em>,
  167. 2000. To appear in <em>Journal of Experimental Algorithms</em>.
  168. <li><A NAME="terraflow:acmgis01"
  169. HREF="http://www.cs.duke.edu/geo*/terraflow/papers/acmgis01_terraflow.pdf">
  170. Flow computation on massive grids</a>.
  171. Lars Arge, Jeffrey S. Chase, Patrick N. Halpin, Laura Toma,
  172. Jeffrey S. Vitter, Dean Urban and Rajiv Wickremesinghe. In
  173. <em>Proc. ACM Symposium on Advances in Geographic Information
  174. Systems</em>, 2001.
  175. <li><A NAME="terraflow:geoinformatica"
  176. HREF="http://www.cs.duke.edu/geo*/terraflow/papers/journal_terraflow.pdf">
  177. Flow computation on massive grid terrains</a>.
  178. Lars Arge, Jeffrey S. Chase, Patrick N. Halpin, Laura Toma,
  179. Jeffrey S. Vitter, Dean Urban and Rajiv Wickremesinghe.
  180. In <em>GeoInformatica, International Journal on
  181. Advances of Computer Science for Geographic Information
  182. Systems</em>, 7(4):283-313, December 2003.
  183. </ol>
  184. <h2>SEE ALSO</h2>
  185. <em>
  186. <a href="r.flow.html">r.flow</a>,
  187. <a href="r.basins.fill.html">r.basins.fill</a>,
  188. <a href="r.drain.html">r.drain</a>,
  189. <a href="r.topidx.html">r.topidx</a>,
  190. <a href="r.topmodel.html">r.topmodel</a>,
  191. <a href="r.water.outlet.html">r.water.outlet</a>,
  192. <a href="r.watershed.html">r.watershed</a>
  193. </em>
  194. <h2>AUTHORS</h2>
  195. <dl>
  196. <dt>Original version of program: The
  197. <a href="http://www.cs.duke.edu/geo*/terraflow/">TerraFlow</a> project,
  198. 1999, Duke University.
  199. <dd><a href="http://www.daimi.au.dk/~large/">Lars Arge</a>,
  200. <a href="http://www.cs.duke.edu/~chase/">Jeff Chase</a>,
  201. <a href="http://www.env.duke.edu/faculty/bios/halpin.html">Pat Halpin</a>,
  202. <a href="http://www.bowdoin.edu/~ltoma/">Laura Toma</a>,
  203. <a href="http://www.env.duke.edu/faculty/bios/urban.html">Dean Urban</a>,
  204. <a href="http://www.science.purdue.edu/jsv/">Jeff Vitter</a>,
  205. Rajiv Wickremesinghe.
  206. <dt>Porting to GRASS GIS, 2002:
  207. <dd> <a href="http://www.daimi.au.dk/~large/">Lars Arge</a>,
  208. <a href="http://www4.ncsu.edu/~hmitaso/index.html">Helena Mitasova,</a>
  209. <a href="http://www.bowdoin.edu/~ltoma/">Laura Toma</a>.
  210. <dt>Contact: <a href="mailto:ltoma@bowdoin.edu "> Laura Toma</a></dt>
  211. </dl>
  212. <p><i>Last changed: $Date$</i>