D8 Algorithm for Hydrological Models

Finds most likely locations for water channels given a potential
2.1K Downloads
Updated 13 May 2010

View License

Step 1: Find flow direction (find min. potential of all adjacent cells)
Step 2: Follow flow direction to sum the cumulative # cells flowing into
a given "minimum" cell.
Step 3: Find the maximum likely channel location in each E-W direction
for a given number of channels.

NOTE: The user should make sure that the upstream portion of the
potential matrix Psi corresponds to first row of the matrix.

USAGES
[channel,I] = d8alg(Psi)
[channel,I] = d8alg(Psi,numChans)
[channel,I] = d8alg(Psi,Accum, numChans)
[channel,I] = d8alg(Psi,Accum,numChans,'plot')

INPUT:
Psi: An MxN array giving the hydraulic potential over a grid.
Accum: The accumulation matrix. This weights each cell with a fluid
volume. Must be same size as Psi.
numChans: The number of channels to be chosen per column.
plotopt: Gives an option to plot images of the potential and the channel
locations, is a string 'plot'

OUTPUT:
channel: The channel locations are specified by a matrix in which all the
elements without channels are 0 and all the elements with a
channel are equal to the accumulation.
I: the index matrix giving the channel locations.

-------------------------------------------------------------------------
EXAMPLE: See example on d-8 tutorial, provided by the following tutorial:
http://www.niu.edu/landform/nonlinearRules.htm

%make potential function
Psi =[14,13,13,14,11;
11,12,14,13,10;
11,10,11,11, 9;
8, 9, 11,10, 8;
6, 8, 10, 7, 9];

Acc = ones(size(Psi));

%make accumulation function. Compare to website accumulation function.
%Note the last row of the website prediction contains an error. One arrow
%in the predicted flow direction is pointed the wrong way.

[channel,I] = d8alg(Psi,Acc,2,'plot');

%The predicted channel locations match with what you would expect from
%the accumulation plot?

Cite As

Joshua Carmichael (2024). D8 Algorithm for Hydrological Models (https://www.mathworks.com/matlabcentral/fileexchange/21682-d8-algorithm-for-hydrological-models), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2006b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories
Find more on Oceanography and Hydrology in Help Center and MATLAB Answers

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.2.0.0

plotting bug now fixed.

1.1.0.0

Many bugs in code. Corrected with test example. More robust and with additional options as well.

1.0.0.0