r.terraflow takes as input a raster digital elevation model (DEM) and computes the flow direction raster and the flow accumulation raster, as well as the flooded elevation raster, sink-watershed raster (partition into watersheds around sinks) and TCI (topographic convergence index) raster maps.
r.terraflow computes these rasters using well-known approaches, with the difference that its emphasis is on the computational complexity of the algorithms, rather than on modeling realistic flow. r.terraflow emerged from the necessity of having scalable software able to process efficiently very large terrains. It is based on theoretically optimal algorithms developed in the framework of I/O-efficient algorithms. r.terraflow was designed and optimized especially for massive grids and is able to process terrains which were impractical with similar functions existing in other GIS systems.
Flow directions are computed using either the MFD (Multiple Flow Direction) model or the SFD (Single Flow Direction, or D8) model, illustrated below. Both methods compute downslope flow directions by inspecting the 3-by-3 window around the current cell. The SFD method assigns a unique flow direction towards the steepest downslope neighbor. The MFD method assigns multiple flow directions towards all downslope neighbors.
Flow direction to steepest downslope neighbor (SFD). |
Flow direction to all downslope neighbors (MFD). |
---|
The SFD and the MFD method cannot compute flow directions for cells which have the same height as all their neighbors (flat areas) or cells which do not have downslope neighbors (one-cell pits).
In order to flood the terrain, r.terraflow identifies all sinks and partitions the terrain into sink-watersheds (a sink-watershed contains all the cells that flow into that sink), builds a graph representing the adjacency information of the sink-watersheds, and uses this sink-watershed graph to merge watersheds into each other along their lowest common boundary until all watersheds have a flow path outside the terrain. Flooding produces a sink-less terrain in which every cell has a downslope flow path leading outside the terrain and therefore every cell in the terrain can be assigned SFD/MFD flow directions as above.
Once flow directions are computed for every cell in the terrain, r.terraflow computes flow accumulation by routing water using the flow directions and keeping track of how much water flows through each cell.
If flow accumulation of a cell is larger than the value given by the d8cut option, then the flow of this cell is routed to its neighbors using the SFD (D8) model. This option affects only the flow accumulation raster and is meaningful only for MFD flow (i.e. if the -s flag is not used); If this option is used for SFD flow it is ignored. The default value of d8cut is infinity.
r.terraflow also computes the tci raster (topographic convergence index, defined as the logarithm of the ratio of flow accumulation and local slope).
For more details on the algorithms see [1,2,3] below.
All these intermediate temporary files are stored in the path specified by the directory option. Note: directory must contain enough free disk space in order to store up to 2 x 80N bytes.
The memory option can be used to set the maximum amount of main memory (RAM) the module will use during processing. In practice its value should be an underestimate of the amount of available (free) main memory on the machine. r.terraflow will use at all times at most this much memory, and the virtual memory system (swap space) will never be used. The default value is 300 MB.
The stats option defines the name of the file that contains the statistics (stats) of the run.
r.terraflow has a limit on the number of rows and columns (max 32,767 each).
The internal type used by r.terraflow to store elevations can be defined at compile-time. By default, r.terraflow is compiled to store elevations internally as floats. Other versions can be created by the user if needed.
Hints concerning compilation with storage of elevations internally as shorts: such a version uses less space (up to 60B per cell, up to 60N intermediate file) and therefore is more space and time efficient. r.terraflow is intended for use with floating point raster data (FCELL), and r.terraflow (short) with integer raster data (CELL) in which the maximum elevation does not exceed the value of a short SHRT_MAX=32767 (this is not a constraint for any terrain data of the Earth, if elevation is stored in meters). Both r.terraflow and r.terraflow (short) work with input elevation rasters which can be either integer, floating point or double (CELL, FCELL, DCELL). If the input raster contains a value that exceeds the allowed internal range (short for r.terraflow (short), float for r.terraflow), the program exits with a warning message. Otherwise, if all values in the input elevation raster are in range, they will be converted (truncated) to the internal elevation type (short for r.terraflow (short), float for r.terraflow). In this case precision may be lost and artificial flat areas may be created. For instance, if r.terraflow (short) is used with floating point raster data (FCELL or DCELL), the values of the elevation will be truncated as shorts. This may create artificial flat areas, and the output of r.terraflow (short) may be less realistic than those of r.terraflow on floating point raster data. The outputs of r.terraflow (short) and r.terraflow are identical for integer raster data (CELL maps).
g.region raster=elev_lid792_1m r.terraflow elevation=elev_lid792_1m accumulation=elev_lid792_1m_accumulation
Spearfish sample data set:
g.region raster=elevation.10m -p r.terraflow elev=elevation.10m filled=elevation10m.filled \ dir=elevation10m.mfdir swatershed=elevation10m.watershed \ accumulation=elevation10m.accu tci=elevation10m.tci
g.region raster=elevation.10m -p r.terraflow elev=elevation.10m filled=elevation10m.filled \ dir=elevation10m.mfdir swatershed=elevation10m.watershed \ accumulation=elevation10m.accu tci=elevation10m.tci d8cut=500 memory=800 \ stats=elevation10mstats.txt
Available at: r.terraflow source code (history)
Main index | Raster index | Topics index | Keywords index | Graphical index | Full index
© 2003-2020 GRASS Development Team, GRASS GIS 7.9.dev Reference Manual