I am using RADAR data to create a map of biomass estimates.

I want to mask out all land susceptible to flooding because water-logged soils affect the backscatter ...and will have an impact on biomass estimate. For part of this process I just want to mask out flood-prone areas around waterbodies.

This will be a very basic operation (because I am doing it over a very large area) and I am happy if it means that I mask out regions that don't get flooded.

I have:

  • a DEM for the region in question
  • a binary raster of water bodies/non-water-bodies area

My suggested approach is to mask out all cells in the radar raster that lie within x-metres of height of the waterbodies.

I am using QGIS but have not been able to identify a simple solution to do this. Can anyone help?

.....One of my thoughts had been to identify the drainage basins of the water bodies and mask out all cells within the basin that lie within x m of the water body ....this is problematic for rivers...which have a full range of heights/drainage basins.

1 Answer 1


A robust but programmatic solution would be something along these lines (roughly, Pythonic pseudocode):

# D is the DEM, W is the true/false water body mask
# delta is the max height difference for flood-prone areas

F = D * W     # F is the DEM with dry land masked out (starting flood positions)
while True:
  changed = False
  for c in F: # for every cell index in raster
    if F[c]: # flood from the cells that are already flooded
      # flood all eligible neighbouring pixels
      # needs defined neighbourhood (4/8 cells around)
      for n in neighbours(c):
        # flood all dry pixels within tolerance and re-mark those too large
        # second condition prevents the highest water pixel from flooding all the area
        if (F[n] == 0 and (F[c] + delta <= D[n])) or F[c] < (F[n] - delta):
          F[n] = F[c]
          changed = True
  if not changed: # stop if no changes have been made during the traversal

In the end, F marks all flood-prone pixels with values larger than 0 and can therefore be used as a mask.

I can't give a QGIS solution due to lack of experience but the implementation should be quite straightforward.

(Giving it a second thought, the algorithm will probably not work if the DEM is too coarse, making large differences in the neighbouring water body cells' heights. Were it not with the rivers, the problem would become much easier.)

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.