I am currently facing a problem. Over the past week, I have been initiated to hydrology within the GIS environment and have finally successfully generated water basins (using the GRASS r.water.outlet) by selecting a pixel in my Flow direction raster generated from a DEM with r.stream.extract

My problem is as follows: I would like to be able to select any pixel (with or without a geoalgorithm) and obtain the whole water basin complex leading to this lake. I know the lake retains water and it's odd because the information generated through my DEM says otherwise. Where a wall should hold the water in, the DEM and all the treatments claim that water goes out through there.

Perhaps the precision of my DEM is lacking, but I can see the wall with a generated Hillshade so I doubt it...

Is there a way to manually modify the DEM for my treatments to detect there is a wall there and the lake is all at the same level? Or is there an existing geoalgorithm that can detect such a lake in the creation of watersheds and water basins? the GRASS commands seem limited in this topic to simply giving me the basins partially through lines.

Mainly though, I would like to be able to do the water basin request from a polygon or a general area in the raster.

1 Answer 1


The GRASS watershed algorithm, by design, continues to route water flow across lakes (or any other flat areas or depressions). It stops when reaching either the edge of the region, or a null cell.

So if you just set your lake to null values the basin will end there. If you have a polygon vector of the lake, then convert to raster with

v.to.rast lake output=lake type=area use=val value=1

Then use a mapcalc expression to set the dem to null over the lake, but keep the dem values everywhere else:

r.mapcalc "dem_lake_null = if(lake==1, null(), dem)"

Now rerun your watershed process with this new dem.

  • The first v.to.rast works fine, however the mapcalc expression returns absolutely nothing. if i re-write with input/output values it would be something like this right? : r.mapcalc "output = if(inputLakeRaster==1, null(), inputDEM)" right? Also, if I modify my DEM like this, would the future water basin request I was talking about return a result for the whole lake?
    – Louis
    Commented May 2, 2017 at 14:40
  • I forgot to mention: set the region to the dem, g.region rast=dem.
    – Micha
    Commented May 3, 2017 at 9:10
  • I've been exploring this problem and the solutions possible for it and found another post in which you answered that helped me alot which is this: gis.stackexchange.com/questions/223992/…
    – Louis
    Commented May 5, 2017 at 13:29
  • 1
    The GRASS module for burning a stream into a DEM raster is called r.carve. [grass.osgeo.org/grass72/manuals/r.carve.html] (man page)
    – Micha
    Commented May 24, 2017 at 16:53
  • 1
    If you NULL out the lake, then the watersheds will end at the lake edge. The only empty parts will be areas that are smaller than the flow accumulation threshold that you set.
    – Micha
    Commented May 24, 2017 at 16:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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