.TH r.terraflow 1grass "" "GRASS 6.4.2" "Grass User's Manual"
.SH NAME
\fI\fBr.terraflow\fR\fR - Flow computation for massive grids (float version).
.SH KEYWORDS
raster, hydrology
.SH SYNOPSIS
\fBr.terraflow\fR
.br
\fBr.terraflow help\fR
.br
\fBr.terraflow\fR [-\fBsq\fR] \fBelevation\fR=\fIname\fR \fBfilled\fR=\fIname\fR \fBdirection\fR=\fIname\fR \fBswatershed\fR=\fIname\fR \fBaccumulation\fR=\fIname\fR \fBtci\fR=\fIname\fR [\fBd8cut\fR=\fIfloat\fR] [\fBmemory\fR=\fIinteger\fR] [\fBSTREAM_DIR\fR=\fIstring\fR] [\fBstats\fR=\fIstring\fR] [--\fBoverwrite\fR] [--\fBverbose\fR] [--\fBquiet\fR]
.SS Flags:
.IP "\fB-s\fR" 4m
.br
SFD (D8) flow (default is MFD)
.IP "\fB-q\fR" 4m
.br
Quiet
.IP "\fB--overwrite\fR" 4m
.br
Allow output files to overwrite existing files
.IP "\fB--verbose\fR" 4m
.br
Verbose module output
.IP "\fB--quiet\fR" 4m
.br
Quiet module output
.PP
.SS Parameters:
.IP "\fBelevation\fR=\fIname\fR" 4m
.br
Name of elevation raster map
.IP "\fBfilled\fR=\fIname\fR" 4m
.br
Name for output filled (flooded) elevation raster map
.IP "\fBdirection\fR=\fIname\fR" 4m
.br
Name for output flow direction raster map
.IP "\fBswatershed\fR=\fIname\fR" 4m
.br
Name for output sink-watershed raster map
.IP "\fBaccumulation\fR=\fIname\fR" 4m
.br
Name for output flow accumulation raster map
.IP "\fBtci\fR=\fIname\fR" 4m
.br
Name for output topographic convergence index (tci) raster map
.IP "\fBd8cut\fR=\fIfloat\fR" 4m
.br
Routing using SFD (D8) direction
.br
If flow accumulation is larger than this value it is routed using SFD (D8) direction (meaningfull only for MFD flow)
.br
Default: \fIinfinity\fR
.IP "\fBmemory\fR=\fIinteger\fR" 4m
.br
Maximum runtime memory size (in MB)
.br
Default: \fI300\fR
.IP "\fBSTREAM_DIR\fR=\fIstring\fR" 4m
.br
Directory to hold temporary files (they can be large)
.br
Default: \fI/var/tmp/\fR
.IP "\fBstats\fR=\fIstring\fR" 4m
.br
Name of file containing runtime statistics
.br
Default: \fIstats.out\fR
.PP
.SH DESCRIPTION
.PP
\fIr.terraflow\fR 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.
.PP
\fIr.terraflow\fR 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. \fIr.terraflow\fR 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. \fIr.terraflow\fR
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.
.PP
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.
.PP
.br
.br
Flow direction to steepest
.br
downslope neighbor (SFD).
Flow direction to all
.br
downslope neighbors (MFD).
.PP
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).
.RE
On plateaus (flat areas that spill out) \fIr.terraflow\fR
routes flow so that globally the flow goes towards the spill cells of
the plateaus.
On sinks (flat areas that do not spill out, including one-cell
pits) \fIr.terraflow\fR assigns flow by flooding the terrain until
all the sinks are filled and assigning flow directions on the filled
terrain.
.RE
.PP
In order to flood the terrain, \fIr.terraflow\fR 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.
.PP
Once flow directions are computed for every cell in the terrain,
\fIr.terraflow\fR computes flow accumulation by routing water using
the flow directions and keeping track of how much water flows through
each cell.
.PP
If flow accumulation of a cell is larger than the value given by the
\fBd8cut\fR 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
\fBd8cut\fR is \fIinfinity\fR.
.PP
\fIr.terraflow\fR also computes the tci raster (topographic convergence
index, defined as the logarithm of the ratio of flow accumulation and
local slope).
.PP
For more details on the algorithms see [1,2,3] below.
.SH NOTES
One of the techniques used by \fIr.terraflow\fR is the
space-time trade-off. In particular, in order to avoid searches, which
are I/O-expensive, \fIr.terraflow\fR computes and works with an
augmented elevation raster in which each cell stores relevant
information about its 8 neighbors, in total up to 80B per cell. As a
result \fIr.terraflow\fR works with intermediate temporary files
that may be up to 80N bytes, where N is the number of cells (rows x
columns) in the elevation raster (more precisely, 80K bytes, where K
is the number of valid (not no-data) cells in the input elevation
raster).
.PP
All these intermediate temporary files are stored in the path specified
by the \fBSTREAM_DIR\fR option. Note: \fBSTREAM_DIR\fR must contain
enough free disk space in order to store up to 2 x 80N bytes.
.PP
The \fBmemory\fR option can be used to set the maximum amount of main
memory (RAM) the module will use during processing. In practice its
\fIvalue\fR should be an underestimate of the amount of available
(free) main memory on the machine. \fIr.terraflow\fR 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.
.PP
The internal type used by \fIr.terraflow\fR to store elevations
can be defined at compile-time. By default, \fIr.terraflow\fR is
compiled to store elevations internally as floats.
A version which is compiled to store elevations internally as
shorts is available as \fIr.terraflow.short\fR. Other versions can
be created by the user if needed.
.PP
\fIr.terraflow.short\fR uses less space (up to 60B per cell, up
to 60N intermediate file) and therefore is more space and time
efficient. \fIr.terraflow\fR is intended for use with floating
point raster data (FCELL), and \fIr.terraflow.short\fR 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).
.PP
Both \fIr.terraflow\fR and \fIr.terraflow.short\fR 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
\fIr.terraflow.short\fR, float for \fIr.terraflow\fR), 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
\fIr.terraflow.short\fR, float for \fIr.terraflow\fR). In this
case precision may be lost and artificial flat areas may be created.
.PP
For instance, if \fIr.terraflow.short\fR 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 \fIr.terraflow.short\fR may be less realistic than those
of \fIr.terraflow\fR on floating point raster data.
The outputs of \fIr.terraflow.short\fR and \fIr.terraflow\fR are
identical for integer raster data (CELL maps).
.PP
The \fBstats\fR option defines the name of the file that contains the
statistics (stats) of the run. The default name is stats.out
(in the current directory).
.SH EXAMPLES
Spearfish sample data set:
\fC
.DS
.br
g.region rast=elevation.10m -p
.br
r.terraflow elev=elevation.10m filled=elevation10m.filled \(rs
.br
dir=elevation10m.mfdir swatershed=elevation10m.watershed \(rs
.br
accumulation=elevation10m.accu tci=elevation10m.tci
.br
.DE
\fR
\fC
.DS
.br
g.region rast=elevation.10m -p
.br
r.terraflow elev=elevation.10m filled=elevation10m.filled \(rs
.br
dir=elevation10m.mfdir swatershed=elevation10m.watershed \(rs
.br
accumulation=elevation10m.accu tci=elevation10m.tci d8cut=500 memory=800 \(rs
.br
stats=elevation10mstats.txt
.br
.DE
\fR
.SH SEE ALSO
\fI
r.flow,
r.basins.fill,
r.drain,
r.topidx,
r.topmodel,
r.water.outlet,
r.watershed
\fR
.SH AUTHORS
.IP "Original version of program: The TerraFlow project,
1999, Duke University.
.br
Lars Arge,
Jeff Chase,
Pat Halpin,
Laura Toma,
Dean Urban,
Jeff Vitter,
Rajiv Wickremesinghe.
.IP "Porting for GRASS, 2002:
.br
Lars Arge,
Helena Mitasova,
Laura Toma.
.IP "Contact: Laura Toma" 4m
.PP
.SH REFERENCES
..IP
.IP \fB1\fR
The TerraFlow project at Duke University
.IP \fB2\fR
I/O-efficient algorithms for problems on grid-based
terrains. Lars Arge, Laura Toma, and Jeffrey S. Vitter. In
\fIProc. Workshop on Algorithm Engineering and Experimentation\fR,
2000. To appear in \fIJournal of Experimental Algorithms\fR.
.IP \fB3\fR
Flow computation on massive grids.
Lars Arge, Jeffrey S. Chase, Patrick N. Halpin, Laura Toma,
Jeffrey S. Vitter, Dean Urban and Rajiv Wickremesinghe. In
\fIProc. ACM Symposium on Advances in Geographic Information
Systems\fR, 2001.
.IP \fB4\fR
Flow computation on massive grid terrains.
Lars Arge, Jeffrey S. Chase, Patrick N. Halpin, Laura Toma,
Jeffrey S. Vitter, Dean Urban and Rajiv Wickremesinghe.
In \fIGeoInformatica, International Journal on
Advances of Computer Science for Geographic Information
Systems\fR, 7(4):283-313, December 2003.
.PP
.PP
\fILast changed: $Date: 2011-11-08 12:29:50 +0100 (Tue, 08 Nov 2011) $\fR
.PP
Full index
.PP
© 2003-2011 GRASS Development Team