View License

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

» Watch video

Highlights from
Upslope area functions

5.0 | 3 ratings Rate this file 11 Downloads (last 30 days) File Size: 292 KB File ID: #15818 Version:

Upslope area functions


Steve Eddins (view profile)


03 Aug 2007 (Updated )

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

| Watch this File

File Information

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.

Required Products Image Processing Toolbox
MATLAB release MATLAB 7.4 (R2007a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (11)
28 Feb 2016 Steve Eddins

Steve Eddins (view profile)

Andres - See influence_map.

Comment only
28 Feb 2016 Andres Penuela Fernandez

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)?


Comment only
26 Feb 2016 Steve Eddins

Steve Eddins (view profile)

Andres - Yes. Look at the function dependence_map.

Comment only
26 Feb 2016 Andres Penuela Fernandez

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.

Comment only
08 Jul 2010 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:

Comment only
07 Jul 2010 Bard R.

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

23 Oct 2009 Charlie seviour seviour

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,

Comment only
18 Jul 2008 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 ;-)

20 Aug 2007 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,

Comment only
20 Aug 2007 Steve Eddins

Hi Wolfgang,

Do you have opinion about should be done with NaNs?

Thanks, Steve

Comment only
19 Aug 2007 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

07 Aug 2007

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.

02 Oct 2007

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

18 Mar 2008

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

25 Sep 2008

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

10 Mar 2009 1.1

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.

26 May 2009 1.2

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

17 Sep 2009 1.3

Use assertElementsAlmostEqual in unit tests.

01 Sep 2016

Updated license

Contact us