File Exchange

image thumbnail

Upslope area functions

version (292 KB) by

Functions for computing and visualizing upslope area, influence map, dependence map



View License

A collection of functions for calculating the upslope area and related measurements for a digital elevation model (DEM).
Based on the method of Tarboton.

See also the upslope area postings on my image processing blog, March-August 2007,

Requires Image Processing Toolbox.

Functions include dem_flow, dependence_map, facet_flow, fill_sinks, flow_matrix, influence_map, pixel_flow, postprocess_plateaus, upslope_area, vis_dem_flow, and vis_map.

Includes a sample DEM data set.

Comments and Ratings (11)

Steve Eddins

Steve Eddins (view profile)

Andres - See influence_map.

Thanks for your answer Steve.

Sorry, but I have another question: is it possible to calculate the dowstream path for each pixel of the catchment (again I would need the coordinates or location of the pixels that are included in each of these downstream paths)?


Steve Eddins

Steve Eddins (view profile)

Andres - Yes. Look at the function dependence_map.

Hi Steve,

Thank you for the algorithm.

I am trying to get the upslope areas for each pixel of the catchment, not just the value of the area, but the coordinates or location of the pixels that are included in each of these upslope areas. Is it possible with your algorithm?

Thank you in advance.

Steve Eddins

Steve Eddins (view profile)

Bard, I am not doing any active algorithm development in this area right now, and I have no plans to enhance this submission. You might want to take a look at Wolfgang Schwanghart's TopoToolbox:

Bard R.

Great algorithm, how would modify it to include flow length as well?

How do you combine this script with flow data?
If the flow was the same for each pixel I could simply multiple the upslope area by a constant. Since this is not the case I need to find a way of inputting my flow data as it calculates the up slope area.

Can anyone enlighten me,

Felix Hebeler

After implementing Tarbotons Dinf algorithm for calculating flow directions I finally stumpled upon your toolbox, which is a lot faster. Thanks for the implementation, maybe if you add a keyword 'flow direction' it could save some other users some work ;-)

Wolfgang Schwanghart

Hi Steve,

areas of interest to geographers often are catchments which commonly have irregular shape. Beyond the watersheds there is often a lack of data. Hence, these values outside the catchment are NaNs. While NaNs inside the catchment may be interpolated the NaNs outside can merely be extrapolated.

Hence, I tried following. I replaced the NaNs in the DEM by -Inf. That works except that it produces an erroneous flow direction on the watershed pixels.

Best regards,

Steve Eddins

Hi Wolfgang,

Do you have opinion about should be done with NaNs?

Thanks, Steve

Wolfgang Schwanghart

Hi Steve,

great contribution! Users of older Matlab versions (R14) need to replace the function hypot(s1,s2) by
s = sqrt(abs(s1).^2 + abs(s2).^2)

One critique: The functions don't handle NaNs.

Best regards, Wolfgang


Updated license


Use assertElementsAlmostEqual in unit tests.


Version 1.4.2 - Added sample DEM data source information to Contents.m. No functional changes in this version.


Version 1.4.1

* Fixed M-file help typo in dependence_map.m.

* Allowed input matrix E to contain NaNs in postprocess_plateaus.m.

* Added unit test directory.

Version 1.4 - modified fill_sinks.m to fill using 8-connectivity instead of 4-connectivity.

Version 1.3. Corrected border NaN computation for dependence_map and influence_map.

Version 1.2. Alter handling of border-connected NaN pixels based on feedback from Wolfgang and others.

Based on feedback I've received, I removed the "plateau flattening" step from the upslope area computation. This step is now provided as a separate function.

MATLAB Release
MATLAB 7.4 (R2007a)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video