A fast, simple and versatile algorithm to fill the depressions of digital elevation models

Fills depressions in a DEM with either a plateau or a gentle slope of given steepness.

You are now following this Submission

Contents:
---------
This is the original algorithm of Planchon & Darboux 2001, A fast, simple and versatile algorithm to fill the depressions of digital elevation models. Catena 46:159-176.

Algorithm:
----------
The original paper can be downloaded here: ftp://130.237.63.22/Common/UllaM/For_Imran/%5B2001%5D%20planchon%20-%20a%20fast,%20simple%20and%20versatile%20algorithm%20to%20fill%20the%20depressions%20of%20digital%20elevation%20models.pdf

Usage (example):
----------------
Z = magic(5) ;
W = nosink(Z) ; % => transforms depressions into flat areas.
epsilon = 0.1 ;
W = nosink(Z, epsilon) ; % => transform depressions into gentle slopes. (a step of at least epsilon is requred between any cell and its lowest neighbor)

Installation:
-------------
1/ copy the file nosink.cpp in your current Matlab working directory
2/ enter this command at the console:
> mex nosink.cpp
3/ test with this command:
Z = nosink(magic(5)) ;
the result will be the magic(5) matrix itself since there is no depression there.

Note on Matlab data types:
--------------------------
The following datatypes are allowed:
int8, int16, int32, int64, float, double.

Footprint:
---------
Time complexity is almost linear (see the paper to learn in which worst case it is not linear)
No memory (except the 'kitchenware') is used beside the 2 matrixes (input and output)

Tests:
-----
Very little tests were done at the moment.
-> Matlab 7.12.0, Ubuntu 12.04, gcc 4.6.3

Please report any bug

Cite As

Olivier Planchon (2026). A fast, simple and versatile algorithm to fill the depressions of digital elevation models (https://www.mathworks.com/matlabcentral/fileexchange/38603-a-fast-simple-and-versatile-algorithm-to-fill-the-depressions-of-digital-elevation-models), MATLAB Central File Exchange. Retrieved .

General Information

MATLAB Release Compatibility

  • Compatible with any release

Platform Compatibility

  • Windows
  • macOS
  • Linux
Version Published Release Notes Action
1.1.0.0

Bug fixing
Support for signed intergers added

1.0.0.0