5

Is there an ArcGIS-like implementation of Flow Accumulation for R?

What I am trying to avoid: Using ArcGIS; Using Grass; Using RpyGEO (but will if need be)

I am aware of the landscape/hydrology packages of RSAGA, enaR, and vegan, but none of these seem to have a flow accumulation function. I have seen previous reference to rsaga.flow.accumulation, but that does not appear to be support any longer.

I have tried ??flow, but only the RPyGEO and a flow path from the Raster package show any promise.

7
  • so do you want to simply avoid the packages you mention or do you need it in R?
    – Roland
    Jan 29, 2014 at 19:36
  • 1
    I would prefer it to be in R, but it is not a deal breaker. I have ArcGIS, Spatial Analyst, and could script it in python, but I like to avoid ArcGIS b/c of license issues. I would like to be able to run this routine on computers without Spatial Analyst licenses. RpyGEO, as you know, still needs the SA license to run sa.FlowAccumulation. The other packages i mentioned, RSAGA, enaR, and vegan do not have a flow accumulation function that I could find, but I would be happy to use them.
    – Mr.ecos
    Jan 29, 2014 at 19:54
  • 2
    For grass you dont need a licence, its free. If you wish to use R, then you could use the spgrass6 package and then call r.terraflow from grass. Furthermore keep in mind, that flow accumulation is a very expensive raster calculation and R is definitely not the right tool for that. Thats probably also the reason, why there is no R package doing that.
    – mace
    Jan 29, 2014 at 20:05
  • 2
    How much of the full workflow are you looking for? Do you want to use R to go from a raw DEM to the flow accumulation? The tricky part is creating the flow direction grid; after that, a (very simple) graph algorithm does the trick. (And, for performance reasons, you wouldn't want to code that in R if you could help it.) See the recent discussion at gis.stackexchange.com/questions/84309/…, which includes a link to an on-line version of the original Jenson and Domingue paper (1988).
    – whuber
    Jan 29, 2014 at 20:48
  • 1
    @whuber, thank you for your thoughts and the link. My ideal would be to use R for the full work flow. Generally [DEM -> flow direction -> accumulation -> >= threshold = stream]. The RSAGA package function rsaga.fill.sinks computes a flow direction using either Planchon and Darboux (2001) or Wang and Liu (2006) [it is only one of those, but the doc says "only for "wang.liu.2001"]. The consensus seems to be that R is a poor choice for this. I see the reason of that argument and they outweigh my desire to contain it within R; I will use python for those bits. Thanks for the help/info!
    – Mr.ecos
    Jan 29, 2014 at 21:15

2 Answers 2

6

You should also take a look at TauDEM (http://hydrology.usu.edu/taudem/taudem5/index.html)

It's a set of command-line .exe files (you run them in the Windows Command Prompt) for calculating flow direction, flow accumulation, and stream thresholds. The input and output of each command is a GeoTiff raster file. TauDEM can be installed stand-alone without ArcGIS.

In R, you can quite easily call third-party command-line executables from your R script with the system() function. There is an example how to use TauDEM in R on their website: http://hydrology.usu.edu/taudem/taudem5/TauDEMRScript.txt

3
  • Thank you @jirikadlec2. This looks really promising! This fits with the previous suggestions of using R to call more appropriate tools for the job and gives access to ArcGIS. Also, as discussed here: Lidar DEM the D-infinity flow direction algorithm fixed some of the problems with D8. I hope to get this working shortly.
    – Mr.ecos
    Jan 30, 2014 at 15:24
  • @jirikdlec2 this was just what I needed. It is very powerful, very fast, and can be called directly from R. The results of Dr. Tarboton's model are quite impressive.
    – Mr.ecos
    Jan 31, 2014 at 15:59
  • Whitebox tools r package now offers several flow accumulation and related hydrological functions. Relatively quick to set up and super fast to run (Quick word of advice- no spaces in file paths) May 8, 2020 at 19:44
0

Give this article a try, it has some good leads for what you are trying to do.

Link to flow accumulation example - R

1
  • 1
    Thank you for your help @dklassen. This is a good start, but unfortunately the author uses RpyGEO in this script. They use rpygeo.geoprocessor("FlowAccumulation_sa"... which still requires an ArcGIS license. However, if I do go the RpyGEO route, I will cite that script/poster.
    – Mr.ecos
    Jan 29, 2014 at 20:07

Not the answer you're looking for? Browse other questions tagged or ask your own question.