Date post: | 14-Sep-2016 |
Category: |
Documents |
Upload: | richard-jones |
View: | 213 times |
Download: | 0 times |
Computers & Geosciences 28 (2002) 1051–1060
Algorithms for using a DEM for mapping catchment areasof stream sediment samples$
Richard Jones*
1289 Tate Drive, Reno, NV 89523, USA
Received 29 May 2001; received in revised form 5 April 2002; accepted 10 April 2002
Abstract
Algorithms are presented which use a digital elevation model (DEM) to create maps of catchment areas of stream
sediment sample points, and to locate optimal sample point locations. Drainage flow directions are determined by the
popular ‘‘D8’’ algorithm, which assigns the drainage from one point on the DEM grid to one of its eight adjacent
neighbors. A new ‘‘drainage enforcement’’ algorithm is presented that insures drainage continuity through flat areas
and out of depressions. This algorithm is based on the priority-first-search weighted-graph algorithm. Relatively simple
methods for defining internal basins and incorporating digitized stream data are also discussed. All of the selected
methods are robust, computationally efficient, and avoid many of the problems associated with other methods. In order
to support this claim, the literature is reviewed and comparisons are made between the chosen methods and other
methods. A full implementation has been created, and the Pascal source-code and Win95 executable program may be
downloaded from the IAMG web site. r 2002 Elsevier Science Ltd. All rights reserved.
Keywords: Algorithms; Digital elevation model; Drainage network; Catchment area; Geochemistry
1. Introduction
Digital elevation models (DEMs) are readily available
data sets that represent the elevation of the earth’s
surface at discrete points in a regular, rectangular grid.
This paper presents computer algorithms that use as
data input a DEM, and output maps showing drainage
patterns and the catchment areas of stream sediment
sample sites.
The examples and illustrations that are presented in
this article are based on a ‘‘1-degree’’ DEM that was
provided by the US Geological Survey (USGS).1 A
1-degree DEM covers an area of 11 in longitude by 11 in
latitude. The DEM contains 1201 rows by 1201 columns
of elevation data, which corresponds to a grid spacing of
3 s of arc. Other DEM data sets are available for the US
and for other countries.
2. The basic algorithm for defining a drainage network
The algorithm that is used here for modeling a
drainage network was first presented by O’Callaghan
and Mark (1984) and Mark (1984).
The basic concept of the algorithm is to model the
drainage network in terms of catchment area. A
catchment area is that area of a watershed that lies
upstream from a point. As the flow of water is traced
downhill from a point, a counter is incremented for all
the downstream points through which the water flows.
The drainage network is defined by the relative counts.
A threshold is chosen which determines when a node
becomes a point on a ‘‘drainage’’. Since larger drainages
have bigger catchment areas than smaller drainages,
they can be ranked by size.
$Code available form server at http://www.iamg.org/CGE-
ditor/index.htm.
*Tel.:+1-775-746-9765.
E-mail address: [email protected] (R. Jones).1http://edcftp.cr.usgs.gov/pub/data/DEM/250/
0098-3004/02/$ - see front matter r 2002 Elsevier Science Ltd. All rights reserved.
PII: S 0 0 9 8 - 3 0 0 4 ( 0 2 ) 0 0 0 2 2 - 5
A separate grid-sized matrix (ca) is initialized to count
the units of catchment area that lie upstream from each
grid node. There are two ways to count ca. The first is to
follow the flow path from each node downhill until it
leaves the grid or ends in a ‘‘pit’’. (A pit is a point that
terminates a flow path in the downhill direction. Water
cannot flow past a pit because none of the adjacent
points around it have a lower elevation.) If there are n
nodes (n ¼ nx � ny), then the calculation requires about
n3=2 to n2 operations because most paths visit many
nodes. The second technique reduces the running time to
O(n log n) by presorting the nodes by elevation. In this
case, each node is visited only once in order of
decreasing elevation, and the downstream counter is
incremented by the total count of the upstream counter.
The downstream direction from a node is determined
by the direction of steepest decent (most negative
gradient). Using only the adjacent, orthogonal nodes
to determine the downstream direction results in a
streaky drainage pattern, but using the eight adjacent
nodes works well. When two or more nodes tie for being
the lowest, one is arbitrarily chosen. The algorithm is
often called the ‘‘D8’’ algorithm (Fairfield and Leymar-
ie, 1991).
2.1. Other methods
The basic D8 algorithm is probably the most popular
method for automated drainage recognition and catch-
ment area determinations (Martz and Garbrecht, 1998).
However, it has a number of deficiencies. The continuity
of drainages does not extend across flat areas or
anywhere that there is a ‘‘pit’’ in the DEM. This subject
is explored in detail in the next section of this paper. The
D8 technique of using only one of eight possible outflow
directions for a node is another problem that has been
addressed in several papers.
In modeling hydrologic flow using a DEM, Quinn
et al. (1991) do not assume that all of the water flowing
out of one unit area goes entirely into one neighboring
cell. In particular, if groundwater also interacts with
surface runoff, then the flow paths may be quite broad
and diffuse. Their method is to partition flow to all
downslope, neighboring cells. However, the distinction
between hydrologic flow units (e.g. water volume, mass
of dissolved contaminant) and catchment area is not
made clear in the article. Whereas certain flow units may
be dispersed, the catchment area from where the flow
originates probably should not be partitioned in the
same way (Tarboton, 1997). In particular, multiple
outflow paths create diffuse and overlapping catch-
ment area boundaries, which conflicts with the basic
definition of catchment area. Also, for mapping catch-
ment areas for stream sediment sampling, sharply
defined catchment area boundaries simplify the final
map product.
The D8 method limits the direction of flow between
two adjacent nodes to only eight possibilities. For most
drainage lines, the individual segments are linked in a
zigzag pattern, which over the length of a particular
drainage approximates the true stream orientation.
However, there will be a discrepancy between the
lengths of the drainages as calculated by summing the
individual segment lengths as compared to some other
method which manages to somehow produce smooth,
curvilinear drainage lines.
The D8 method fails to model the average flow
direction for laterally extensive, planar slopes. Flow
lines on these slopes are parallel, and should be oriented
down-dip. However, if the slope is featureless, the
absence of ‘‘banks’’ means that the DEM will not
provide the necessary information to jog the drainages
into a zigzag pattern. Hence, the D8 algorithm produces
drainages that are not, in general, oriented down-dip,
but are instead oriented in one of the eight principal
directions. Fairfield and Leymarie (1991) propose a
stochastic function that is applied to the gradient
determinations. The random component in this function
provides the necessary ‘‘jog’’ to cause the flow lines to
zigzag even on featureless slopes, thus producing
drainage lines that are more-or-less parallel to the
slope’s dip direction. Tarboton (1997) proposes using
two outflow paths to overcome the problem. By a rather
complicated formula, the flow direction from a node is
assigned a direction over the range of 0–3601. However,
the discrete grid spacing precludes using this directional
angle in a direct manner. Therefore, the catchment area
is partitioned between the two nodes that lie on either
side of the ideal flow direction.
Both the methods of Fairfield and Leymarie (1991)
and Tarboton (1997) solve the directional problem of
the D8 algorithm for a planar, long slope. However, the
solution may not be worth the effort. First, the slope
must be featureless, otherwise the D8 method would
work. By any method the individual ‘‘drainages’’ are
arbitrarily located on a featureless slope. It may not be
important to have properly oriented drainage lines when
the drainages do not even exist in the real world.
Secondly, highly planar slopes are unusual in most
terrain. Hence, the special methods that are proposed
for these areas make the overall calculation less efficient
and can introduce undesirable features in other areas
where the DEM is well conditioned for the basic D8
algorithm to work.
O’Callaghan and Mark (1984) specify that some
threshold is used to identify when a pixel is considered
to be on a drainage line. Regardless of how the threshold
is chosen, the drainage lines provide important visual
information about flow directions. The method recom-
mended here is to determine the threshold visually by
trial and error. However, some research has been
applied towards more definitive criteria. Tarboton et al.
R. Jones / Computers & Geosciences 28 (2002) 1051–10601052
(1991) provides statistical methods for determining the
threshold. Tribe (1992) suggests that the criteria for
the drainage network should be a close match between
the DEM-derived network and those ‘‘blue lines’’ that
are shown on published maps to represent rivers and
creeks. Tribe found that a threshold that works well for
drainages in upland areas is generally too small for low-
relief areas. She was able to get a better match with the
blue lines when the DEM-based drainages ended at
‘‘valley heads’’, which are determined by the elevation
gradients in the DEM.
3. Problems with DEM data
The basic D8 algorithm generally works well for small
drainages in areas of high relief. However, the major
drainages are not delineated (Fig. 1). There are some
inherent problems with DEM data with respect to
drainage analysis.
Major streams occur in alluvial valleys with low
stream gradients. If the topographic gradient is less than
the precision of the DEM elevation data, then flats will
invariably occur such that there is no immediately
adjacent downhill direction from certain nodes. For
example, the USGS 1-degree DEM data has elevations
rounded to the nearest meter, and the x (longitude) and
y (latitude) spacing translates to about 70 and 90m,
respectively, in the horizontal plane. Thus, if a stream
has a gradient of 1% or less, then the DEM will show
adjacent points along the course of the stream with no
gradient at all. In the D8 algorithm, a drainage
terminates at a point where none of the adjacent points
are downhill.
Precision is not the only problem with the raw DEM
data, a point apparently missed by most writers on the
subject (e.g., 2 Martz and Garbrecht, 1998; Mark, 1984).
Lakes are truly flat, and unless they are in closed basins,
they are part of drainage networks (Turcotte et al.,
2001). Even in areas of relief, spurious pits may occur.
Consider, for example, an area where the rivers occur in
incised channels. Suppose a stream flows NNE from a
node located at (x; y) and passes between the nodes at
(x; yþ 1) and (xþ 1; yþ 1). If these latter points occur
on the banks of the stream they probably will have
elevations greater than the elevation at (x; y). Further-more, the fact that the stream actually flows NNE from
the point (x; y) is not recorded in the DEM data. Hence,
Fig. 1. Basic algorithm for calculating catchment area grid (ca) generally fails to produce desired result on raw DEM data. Here,
drainage pattern is shown using threshold of 1/8 sq. miles. Larger rivers are not shown, and even smaller streams located in upland
areas of higher topographic relief are disrupted by ‘‘pits’’. Map is based on northern half of Wells-west 1-degree DEM, which contains
721,801 points. Of these, 101,042 points are pits without drainage to any one of eight adjacent points. Map contains 2994 drainages,
largest of which has a catchment area of only 2.81 sq. miles.
2Saunders, W., 1999. Preparation of DEMs for use in
environmental modeling analysis. http://www.esri.com/library/
userconf/proc99/proceed/papers/pap802/p802.htm.
R. Jones / Computers & Geosciences 28 (2002) 1051–1060 1053
the drainage calculation needs to predict the true
direction of stream flow at points where the DEM has
spurious pits.
The problems with flats and spurious pits are
compounded by the potential to have real basins located
within the boundaries of the grid. Basins may include
the margin of an ocean, a closed lake basin, or a playa.
4. Eliminating spurious pits and flats
Flat areas and spurious pits are eliminated from the
elevation grid by adjusting the grid values so as to insure
that there is at least one downslope direction for each
node in the grid. The approach presented in this paper
uses a priority-first-search algorithm (PFS) to find an
‘‘outlet’’ for a pit. Then along the PFS path from the
outlet back to the initial starting point the elevations are
adjusted, which in effect creates a trench with a
continuous, finite gradient.
PFS is a well-known, weighted-graph algorithm with
an established algorithmic structure and well-known
performance characteristics (Sedgewick, 1988). The
algorithm is robust and will solve a variety of problems
just by changing a ‘‘priority function’’ and/or by
changing the terminating conditions. Drainage enforce-
ment is modeled as a classical ‘‘shortest-path’’ problem.
In graph terminology, points, or nodes, are called
vertices. Any given vertex may be connected to one or
several other vertices. The connections between each
vertex are usually given in a data structure, referred to as
an ‘‘adjacency list’’. However, in this application, the
adjacency list is implicit in the x; y coordinates of the
vertex/node, since the DEM grid structure automatically
defines the eight nearest nodes as being ‘‘adjacent’’. In
PFS, every vertex is in one of three states: it is ‘‘on the
tree’’, it is ‘‘in the queue’’, or it has not yet been
examined. The algorithm is initialized by putting the pit
node on the tree, which thereby becomes the root node
for the tree. The iterative part of the algorithm then
commences and builds the rest of the tree. The iteration
terminates when the last vertex added to the tree is an
‘‘outlet’’ point for the drainage. An outlet may either be
a point with a lower elevation than the point at the root
node, the edge of the grid, or a drainage-terminating
point predefined as a basin. It may be necessary to adjust
the elevation of the outlet if the average slope between
root node and the outlet is less than a specified
tolerance. Finally, the tree is traced from the outlet
back to the pit located on the root node, and the grid
elevations are adjusted for every point to create a
uniform gradient.
The code that defines ‘‘priority’’ is contained in a
single subroutine which compares the relative priority
between two vertices. The subroutine is implemented as
a function that returns either true or false, depending
upon whether or not vertex A has higher priority
than vertex B. For drainage enforcement, priority is
based on a small set of nested criteria. In seeking an
outlet for a pit, the path must go through the lowest pass
available. If there is more than one path that satisfies
this criteria, the path taken is the one that goes down in
elevation the most. And for paths that are equal in these
criteria, the path with the shortest total length is
selected.
The data structure associated with each vertex
contains all the information necessary to define its
priority in the priority queue, its adjacency list, and its
position in the tree. The PFS algorithm would require
considerable memory if a vertex record were allocated
for each grid node. As described, extra memory on the
order of n ð¼ nx � nyÞ is required since the adjacency list
for each vertex is implicit in the structure of a grid.
However, in a practical application, any invocation of
the PFS routine will examine only a small fraction of the
total number of nodes in the grid. Therefore, vertex
records are allocated dynamically as needed, and the
adjacency information is contained in a grid of 32-bit
pointers. The pointers are initialized to nil, which also
serves as a sentinel. Whenever the algorithm needs to
find an adjacent vertex, it examines the appropriate grid
node. If the node is nil, a new vertex record is allocated.
If it is not nil, it points to an already-allocated vertex
record. Each time the PFS routine finishes its job in
locating an outlet, all vertices on the tree and in the
queue are deallocated and their corresponding grid
pointers are reset to nil.
Hutchinson (1989) suggests two other features for
incorporation into the pit-removal algorithm. (1) Pits
are cleared in order of increasing elevation. This
enhancement tends to improve the placement of the
drainages in their lower reaches where they join other
drainages. (2) If the elevation difference between the
root node and the last vertex added to the tree is greater
than a specified tolerance, the PFS routine is aborted
and the pit is retained as a sink-point in the DEM.
4.1. Comparison with other drainage enforcement
algorithms
Jenson and Domingue (1988) introduced a drainage
enforcement algorithm (the ‘‘J&D algorithm’’) that has
proven to be popular. The method has been implemen-
ted in the Arc/Info Grid module as part of the Fill
algorithm (see footnote 2). The method works in two
stages. In the first stage, pits are ‘‘filled’’ by increasing
the elevations of the nodes within each depression to the
level of the lowest node on the depression boundary.
The procedure essentially converts every depression into
a flat area that has at least one external node on its
border which has a lower elevation than the flat. The
second stage assigns flow directions to the nodes in flat
R. Jones / Computers & Geosciences 28 (2002) 1051–10601054
areas by an iterative procedure. In each iteration, nodes
are assigned flow directions that point to a neighboring
node if the neighboring node has a flow direction. Flow
direction assignments iteratively grow into the interior
of the flat from the outlet node(s).
(Note: In the J&D algorithm, the elevations of points
in the flat areas are not explicitly adjusted. Instead, a
separate grid-size matrix of flow directions is main-
tained, and it is these values which are modified in the
second stage. The approach taken by the PFS algorithm
is to modify the elevation grid, thus making redundant
the flow-direction matrix since flow directions can be
calculated with the D8 algorithm.)
Pit filling is essentially a filtering operation that
removes depressions from the DEM. This approach is
justified by assuming that depressions are data errors
(Jenson and Domingue, 1988; Martz and Garbrecht,
1998). In contrast, an assumption in this paper is that
DEM data is generally correct if it is used to calculate
drainage networks. The PFS routine obviously violates
this assumption. However, the D8 algorithm requires
some adjustments. A second assumption is that the finite
spatial resolution of the grid precludes an exact
determination of the true stream locations if the stream
channels are small enough to snake between the grid
nodes. PFS uses good strategy for finding an outlet and
if the pit is in a depression, for finding a pass. More
generally, it probably locates drainages to a reasonably
good approximation. Unlike the J&D algorithm, PFS
only adjusts the DEM along lines that are one pixel wide
and preserves well defined topographic features within
depressions.
Martz and Garbrecht (1998) presented a different
method for flat areas. After all the nodes in a flat area
are identified, an iterative routine is invoked to
recontour the area into a slightly V-shaped valley. They
also modified the pit-filling routine to accommodate a
‘‘breaching’’ criteria. Depressions may not be filled to
the level of a pass on the rim of the depression if certain
conditions are met. In that situation, the rim is
‘‘breached’’, whereby a channel is created through the
pass to an external outlet.
Martz and Garbrecht (1998) justify their method for
dealing with flat areas partly because they were
dissatisfied with the tendency for the J&D algorithm to
produce parallel drainage channels. However, from
diagrams presented in their paper, it appears that their
algorithm still has a tendency to produce a lot of
parallel channels. In contrast, PFS has just the opposite
effect. If the starting point for pit elimination in a flat
area is randomly selected (as opposed to, say, always
selecting a point on one edge of the flat), then the
channel created by PFS will be used as an outlet for
subsequent channels. Since the priority condition
specifies that channels will be created by the shortest
path (when all the other priority conditions are equal),
PFS tends to create an orthogonal drainage pattern in
flat areas.
Tribe (1992) also found that the parallel drainage lines
of the J&D algorithm to be unrealistic, and proposed a
new method. The method involves defining a main flow
path through the flat to an outlet, and directing the flow
paths for nearby points in the flat towards the main
path. However, because the main flow path is defined as
a straight line, it could cut through an area of higher
elevation.
Hutchinson (1989) implemented a drainage enforce-
ment technique for a program that creates raster DEMs
from sparse, scattered elevation data. The method first
identifies pits and saddles. Then, for all the downhill
neighbors around each saddle, traces a path from the
neighbor to either a pit or the edge of the grid using the
D8 technique of steepest gradient. For each pit, an
ordered chain is constructed from the pit, through the
lowest, nearby saddle, and to either a pit with a lower
elevation or to the edge of the DEM. The elevations of
the DEM along this path are set to produce an
approximately linear decent. Following the drainage
enforcement routine, the entire DEM is re-interpolated
using a finite element interpolation method. The control
points for the interpolation include the original,
scattered data points, and the points generated along
the drainage-enforcement paths.
Hutchinson’s program enjoys the advantage of being
able to re-interpolate the grid in order to smooth out the
topography around the ‘‘channels’’ created by the
drainage enforcement routine. Unfortunately, given an
existing DEM, the only option for smoothing the DEM
is by filtering, which will oversmooth some well-defined
surface features (Hutchinson, 1989).
Fairfield and Leymarie (1991) handle depressions
using a sequence of steps: (1) A pit is identified (which is
the low point in the depression). (2) The nodes in the
catchment area for the pit are identified. (3) The lowest
point on the rim of the catchment area is selected. (4)
The drainage line is traced from this point downhill to
the pit. (5) Finally, the flow directions along this line are
reversed. This method is basically the same as Hutch-
inson’s algorithm, except in the way that the pass is
found. Neither Fairfield and Leymarie (1991) nor
Hutchinson (1989) describe methods for handling flat
areas.
Using recursive or stack-based algorithms, the nodes
in a flat area or a depression can be identified in a
time proportional to the number of nodes—an OðnÞruntime performance (Fairfield and Leymarie, 1991;
McCormack et al., 1993). In contrast, PFS is an
Oðv log vÞ algorithm, where v is the number of nodes
actually checked (Sedgewick, 1988). V is usually smaller
than n; especially for depressions, because PFS is
finished once an outlet is found, and it does not need
to examine every node in a flat area or depression to do
R. Jones / Computers & Geosciences 28 (2002) 1051–1060 1055
that. Hence, in practice the performance of PFS is hard
to beat.
All of the drainage-enforcement algorithms described
previously use entirely different procedures for proces-
sing depressions and flat areas, except PFS, which
effectively handles both conditions.
5. Defining internal basins and constraining the location
of drainages
PFS works reasonably well for preparing a DEM grid
for drainage delineation in areas of moderate relief,
where drainages are well constrained by topography,
and are without internal basins (Fig. 2). However, two
major problems remain to be addressed. First, the
calculated drainages are generally not close to the real
drainages in areas of broad, flat topography. The fact
is, there is no information in the original DEM data
that can be used to locate the actual positions of
drainages when the topography is flat. Secondly, PFS
will find an outlet for a pit even if it occurs in a valid,
closed basin.
A basin is a region-type object that has no internal
drainage, and a point-like sink may be defined where an
individual drainage simply disappears. Constraining the
PFS routine to terminate whenever a predefined ‘‘sink’’
node is encountered is achieved by flagging all nodes
that are suppose to be sinks with a special attribute. A
separate grid of boolean values, okPit, has each node set
to either true or false depending upon whether the node
is suppose to be a sink or not.
The locations of drainages are constrained by reading
a file of line-objects, and changing the grid elevation for
every node in the line to some suitable value. There are
two possible modifications: predefined drainage ‘‘chan-
nels’’ are ‘‘cut’’ into the DEM by decreasing the Z
coordinate along the line of the channel. Although the
channels thus defined are not necessarily drainages (they
may be flat-bottomed depressions), they will be drai-
nages after the pit-elimination procedure is completed.
‘‘Ridges’’ are the opposite of channels because the Z
coordinate is increased, which inhibits the nodes from
ever being on a drainage.
User-defined basins, sinks, channels, and ridges
represent a variety of spatial objects. Hence, a geo-
graphic information system (GIS) compatible file format
is used to enter the data as input into the drainage
program. For each point-, line-, and area-object there is
an associated attribute code. Four attributes are defined:
(1) ‘‘sinks’’ include points, lines and areas; (2) a ‘‘seed’’
point will fill an area bounded by lines with sinks; (3)
predefined drainage ‘‘channels’’; and (4) ‘‘ridges’’. The
program shifts each real-world coordinate to the nearest
grid node, and sets either okPit or Z to the appropriate
value, depending upon the attribute.
Fig. 2. Same map area as Fig. 1, but with drainage continuity enforced on elevation grid using PFS routine that is described in text.
Map contains 156 separate drainage basins, and just four largest account for 1200 sq. miles of watershed, or 70% of total map
coverage.
R. Jones / Computers & Geosciences 28 (2002) 1051–10601056
5.1. Comments concerning the use of ancillary streamline
data
The method outlined above for incorporating stream-
line data is simple, but effective. However, it does create
unrealistic depth-extents for the ‘‘cut’’ channels. Given
the original, pitted DEM and its derivative, drainage-
enforced DEM, it is possible to calculate a second
drainage-enforced DEM that has all the drainage
characteristics of the first, but with a minimum amount
of discrepancy with the original. However, for catch-
ment area calculations the depth-extent of the channels
is immaterial because only the directional information,
as defined by the D8 algorithm, is used.
Recently, several papers have been presented which
address the subject of using streamline data in conjunc-
tion with DEMs for basin/watershed analysis (e.g.
Turcotte et al., 2001, Saunders (see footnote 2), and
references therein). Often referred to as ‘‘stream burn-
ing’’, these methods are essentially the same as that
which was described previously for channel-type con-
straints, except that they more frequently change the off-
stream nodes of the DEM rather than the on-stream
nodes. Hutchinson (1989) was one of the earliest to
report using streamline data in conjunction with DEM
grids, but he was generating the DEMs, a somewhat
different subject.
Saunders (see footnote 2) reported a situation where
the D8 algorithm failed to delineate accurately two
watershed boundaries for an area along the topogra-
phically flat, southeast Texas coast. These results were
obtained using Arc/Info, which has built-in pit removal
and flow accumulation routines for DEM data. Efforts
to get the calculated watershed boundaries ‘‘right’’
included intensive editing of streamline data, and testing
four different stream burning algorithms. Only the most
sophisticated and computationally intensive stream-
burning algorithm produced satisfactory results,
although it, too, was not exactly ‘‘right’’. Saunders
concludes that improvements in the way in which the
elevations are adjusted by stream burning could lead to
better results. This suggestion is a good one. For
example, Saunders already has the ‘‘known’’ watershed
boundary, which could be applied as a ridge-type of
constraint, thus forcing the D8 and pit-removal algo-
rithms to the ‘‘right’’ solution irrespective of the
streamline data or the sophisticated algorithms. Also,
the pit-removal algorithm is a critical factor influencing
the final map. Hence, a better pit-removal algorithm
could also lead to better results.
Turcotte et al. (2001) used both streamline data and
the boundaries of lakes to model stream flow in an area
in Quebec, Canada where numerous lakes occur in parts
of the drainage network. Where streamline and lake
information was available, flow directions were obtained
solely by this data. In particular, the D8 approach
cannot be used to model flow directions in lakes. In
areas not covered by streamline data or lake boundaries,
flow directions were modeled using the D8 algorithm.
Hellweger3 reported a situation where there was an
obvious discrepancy in the position of a stream as
indicated topographically by a DEM and as indicated by
streamline data. From the figures in Hellweger’s paper,
it appears that there is enough relief in the supposed-
problem area for the D8 algorithm to work well.
However, after ‘‘burning in’’ the streamline data, the
DEM contained two, parallel, nearby troughs. Although
the main drainage followed the burned-in channel, a few
of the smaller tributaries flowed into the other trough,
and therefore did not merge with the main drainage. In
an effort to correct the problem, Hellweger (see footnote
3) created a program, Agree.aml, that ‘‘reconditioned’’
the DEM in the vicinity of the streamlines. In effect, the
program created a V-shaped channel that was wide
enough to remove the ridge that was situated between
the two troughs. The program may have solved the
‘‘reconditioning’’ problem that was initially created by
the streamline data, but it could also lead to other
problems. For example, Saunders (see footnote 2) noted
that the Agree algorithm produced an artifact in a
watershed boundary that was not apparent in other
stream burning techniques. Automatic filtering or
‘‘reconditioning’’ can alter well-defined surface features
in a DEM (Hutchinson, 1989). In Hellweger’s problem
area, good results could probably be achieved by simply
omitting the streamline data.
6. Producing drainage maps
The drainage pattern may be displayed in either raster
format or vector format. Raster images are the simplest,
since there is a one-to-one correspondence between the
catchment area grid and the final raster image. Pixels
may be color coded differently to indicate the size of the
drainage by using various thresholds of catchment area
as criteria for assigning the colors.
Vector output is more involved since it requires that
individual grid elements be linked into line segments or
grouped into sequences of line segments (polylines).
Each drainage is traced upstream from its terminal node
until the ca value is less than the drainage threshold.
Locating the terminal node is easy, since all streams
must terminate at a sink. (The edge of the DEM is also
initialized with an outlying border of sinks.) Hence, if
these points have a ca value greater than the drainage
threshold, then they are used as starting points for the
tracings. The definition of ‘‘upstream’’ is a derivative
3Hellweger, F., 1997. Agree-DEM surface reconditioning
system. http://www.ce.utexas.edu/prof/maidment/gishydro/fer-
di/research/agree/agree.html.
R. Jones / Computers & Geosciences 28 (2002) 1051–1060 1057
definition: point a is upstream of point b only if point b
is downstream of point a. For any node on the grid there
are 8 possible Upstream directions. Therefore, it is
expedient to first calculate the grid upstream, which is
defined as a matrix of type SetOfDirections, where the
set of directions are the eight enumerated values of east,
northeast, north, etc. Tracing the drainages upstream
from a given node then proceeds in the direction
indicated by UpStream. Since UpStream can contain
two or more directions (which occur at forks in the
stream), a depth-first-search stack is used to process all
tributary branches.
7. Calculations for stream sediment sampling
If simply mapping the locations of drainages is the
objective, then using a DEM to achieve this is a poor
approach to solving the problem. The use of a DEM
implies an interest in some spatially extensive character-
istic of the terrain, not just the spatially restricted
drainage lines. The practical applications presented here
are to use a DEM to help in the design phase of a stream
sediment sampling program, and to map the catchment
areas of stream sediment samples.
Experience in the arid terrain of Nevada, USA,
indicates that the catchment area for potential sample
sites should be between 2 and 8 sq. miles (5–20 km2). For
a 1 degree DEM, 412 grid cells equals 1 sq. mile, so
lower and upper thresholds can be calculated for
displaying stream segments that are properly sized for
sampling (Fig. 3). Also, the downstream endpoint of
these segments is the most optimal sampling point along
the stream. (In practice, the point that is actually
sampled will be determined by additional factors,
including geology, accessibility, and the characteristics
of the stream as determined in the field.)
Mapping the catchment area for a given set of sample
points is essentially the same as tracing the drainages,
except that the starting point for each trace is the sample
point itself, and all upstream points are to be included in
the catchment area. In Fig. 4, a map of some sample
catchment areas is shown as a colored raster image. A
GIS program was used to superimpose ‘‘layers’’ of
additional information, including the DEM-calculated
drainages. Tabulated data concerning the catchment
areas can also be generated.
9. Program implementation notes
The program ‘‘Drainage’’ was coded in Pascal for
Borland’s Delphi compiler for Windows 95. Both the
source code and the executable program may be
downloaded from the IAMG web site (http://www.iam-
g.org/CGEditor/index.htm).
Program parameters are entered in a text file, which
can be modified using a text editor. These parameters
Fig. 3. Map showing drainage lines that were constrained by USGS DLG data. Black dots represent optimal sample sites for planning
a stream sediment sampling program. Criteria for sample sites are that they must have a catchment area of at least 2 sq. miles, but not
more than 8 sq. miles. Thick gray outlines are water reservoirs, which are classified as ‘‘sinks’’ for this application.
R. Jones / Computers & Geosciences 28 (2002) 1051–10601058
include numerical constants and input/output file
names. The geographical constraints, if any, are read
from a file that is formatted in MapInfo interchange
format (MIF). Program results are written to disk in
tab-delimited text, MIF, and colored BMP file formats.
Additional information concerning the program’s para-
meters and I=O data formats is included with the
executable program on the IAMG web site.
The slowest part of the drainage program is in the
presort used to order the grid points by elevation prior
to the calculation of the catchment area grid, ca. This is
an Oðn log nÞ algorithm, where n is the number of grid
points. The pit elimination routine makes a single pass
through the elevation grid to identify pits. Although the
PFS subroutine that is used to eliminate a pit has
Oðv log vÞ running time, the overall running time for pit
elimination is significantly faster than the sorting
routine. Tracing drainages is linear in the number of
nodes in the drainages, and mapping sample catchment
areas is linear in the area of the catchment areas.
Therefore, these calculations are also relatively fast.
The program uses 17 bytes per node for the
calculation of ca, or about 25 mbytes for a full 1 degree
DEM data set. The memory required to eliminate
spurious pits is data dependent. The worst-case scenario
would be an elevation grid that consists of one large
depression bounded by a rim one pixel wide. For this
contrived example, pit elimination requires about 80
mbytes for a full 1-degree DEM. However, some tests on
real DEMs indicate that it is unlikely that pit elimina-
tion is a memory-limiting factor for real DEMs.
10. Concluding remarks
Analytically, complex three-dimensional surfaces can
be made computationally tractable for computer proces-
sing by digitizing the surface at discrete points on a
regular grid. A certain amount of information is lost in
this process. For some types of computation, this loss is
not a major problem. For example, DEMs are
commonly used as input data for contouring programs.
However, for other computations the information lost is
fundamental to the problem. In the situation of drainage
basin analysis, the DEM does not contain any informa-
tion that directly locates drainages and the terminations
of drainages at sinks. Also, the ability to infer the
locations of drainages by computational analysis of the
elevation grid is limited. This article addresses techni-
ques that correct the deficiencies in the rasterized
elevation data so that drainages may be reasonably
located. Once a drainage network has been defined, the
problem of analysis can proceed to the next step. The
application presented here is to calculate the catchment
areas for stream sediment samples and to identify
‘‘optimal’’ sample sites.
Fig. 4. Map of catchment areas of stream sediment samples is created in color-coded bitmap format. (Here, colors have been
reassigned to gray-scale.) Hypothetical sample points that are shown (as black dots) include some samples that are located within
catchment areas of other samples. Program assigns non-unique colors for the individual catchment areas, but no two adjacent or
‘‘included’’ areas have same color. Separately, a table is output which identifies for each sample its color, its catchment area in sq.
miles, and area of any included samples.
R. Jones / Computers & Geosciences 28 (2002) 1051–1060 1059
Acknowledgements
I thank my wife, Laura McKerrow, Mark Mihalasky,
Graeme Bonham-Carter, and two C&G reviewers for
making numerous suggestions to improve the paper.
References
Fairfield, J., Leymarie, P., 1991. Drainage networks from grid
digital elevation models. Water Resources Research 27 (5),
709–717.
Hutchinson, M.F., 1989. A new procedure for gridding
elevation and stream line data with automatic removal of
spurious pits. Journal of Hydrology 106, 211–232.
Jenson, S.K., Domingue, J.O., 1988. Extracting topographic
structure from digital elevation data for geographic
information system analysis. Photogrammetric Engineering
and Remote Sensing 54 (11), 1593–1600.
Mark, D.M., 1984. Automated detection of drainage networks
from digital elevation models. Cartographica 21, 168–178.
Martz, L.W., Garbrecht, J., 1998. The treatment of flat areas
and depressions in automated drainage analysis of raster
digital elevation models. Hydrological Processes 12, 843–855.
McCormack, J.E., Gahegan, M.N., Roberts, S.A., Hogg, J.,
Hoyle, B.S., 1993. Feature-based derivation of drainage
networks. International Journal of Geographical Informa-
tion Systems 7 (3), 263–279.
O’Callaghan, J.F., Mark, D.M., 1984. The extraction of
drainage networks from digital elevation data. Com-
puter Vision, Graphics, and Image Processing 28,
323–344.
Quinn, P., Beven, K., Chevallier, P., Planchon, O., 1991. The
prediction of hillslope flow paths for distributed hydro-
logical modelling using digital terrain models. Hydrological
Processes 5, 59–79.
Sedgewick, R., 1988. Algorithms, 2nd edn. Addison-Wesley,
Reading, MA.
Tarboton, D.G., 1997. A new method for the determination of
flow directions and upslope areas in grid digital elevation
models. Water Resources Research 33 (2), 309–319.
Tarboton, D.G., Bras, R.L., Rodriguez-Iturbe, I., 1991. On the
extraction of channel networks from digital elevation data.
Hydrological Processes 5, 81–100.
Tribe, A., 1992. Automated recognition of valley lines and
drainage networks from grid digital elevation models:
a review and a new method. Journal of Hydrology 139,
263–293.
Turcotte, R., Fortin, J.-P., Rousseau, A.N., Massicotte, S.,
Villeneuve, J.-P., 2001. Determination of drainage structure
of a watershed using a digital elevation model and a
digital river and lake network. Journal of Hydrology 240,
225–242.
R. Jones / Computers & Geosciences 28 (2002) 1051–10601060