From a DEM of a watershed, how is possible to calculate the longest flow path?
I know this questions has been asked before but I haven't found a complete solution yet.
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It only takes a minute to sign up.Sign up to join this community
After a long and painful process, I found a way to do it combining GRASS GIS and QGIS with GRASS.
Here is how I did it:
In QGIS load the DEM raster.
Using GRASS for QGIS run the r.watershed command (from the processing toolbox) setting an appropriate threshold.
In my case, I always try to make the watershed no bigger than the “acceptable area limit” for the Rational Method, which normally is 2 to 5 km², so (for example) using the ASTGTM2 DEM with a cell resolution of approximately 30m x 30m, the threshold should be (considering 2 km² of watershed): 2000000 / (30*30) = 2222 ≈ 2200.
Save all the outputs of the r.watershed command, specially Drain Direction and Streams.
Using the results r.watershed command, pick the desired outlet point coordinates and run r.water.outlet command. The result will be a raster with the complete basin that flows directly to your desired outlet point.
Clip the original DEM raster with using the basin result from step 3. This can be done by transforming the basin raster to a vector polygon and then clipping the DEM with that polygon or masking the DEM with the basin raster.
Once again, run the r.watershed only this time using the clipped DEM from step 4. The only result useful for the analysis will be the Drain Direction, the rest is optional.
This is the tricky part. Now you have to open GRASS GISS (the standalone program. It gets installed automatically with QGIS).
Create or open a mapset.
Two GRASS addons should be loaded before doing anything else: r.stream.distance and r.lfp. To do this in the console panel type g.extension and when asked for the new command type r.stream.distance, click execute and then repeat with l.lfp.
Restart GRASS GIS
Now load the Drain Direction raster from the clipped DEM, this is done with the command r.in.gdal and selecting the Drain Direction raster file.
Set up the correct GRASS region using the command g.region and using the Drain Direction raster as the input.
Once done, run the command r.lfp, the input raster should be the Drain Direction of the basin and the coordinates of the output point.
This point should be located on a stream from the Streams raster result of the r.watershed from step 3.
The result of the r.lfp command is a raster with the longest flow path of the basin. This raster can be transformed to a vector line with the command r.to.vect.line.
Maybe my whole process can be done more efficiently but this is how I manage to do so.
Hope someone someday find it helpful.
The new r.lfp produces a vector map with the longest flow path. The old
r.lfp + r.to.vect may result in hydrologically invalid output.