Geoscience Reference
In-Depth Information
Fig. 7.14
Schematic of calculation of l ow accumulation by the D8 method.
A recommended value for
w
is 1.1; higher values would concentrate the l ow
in the direction of the steepest slope, while
w
=0 would result in extreme
dispersion. In the following sequence of commands, we i rst select those
gradients that are less than zero and then multiply the gradients by the
weighting.
w = 1.1;
flow = (grads.*(-1*grads<0)).^w;
We then sum up the upslope gradients along the third dimension of the
flow
matrix. Replacing all upslope gradient values of 0 by a value of 1 avoids the
problems created by trying to divide by zero.
upssum = sum(flow,3);
upssum(upssum==0) = 1;
We divide the l ows by
upssum
to obtain fractional weights that add up to a
total of one. h is is achieved separately for each layer of the 3D
flow
matrix
using a
for
loop: