Using QGIS I'm trying to analyse an area/DEM with these two criteria: -Even sloping terrain steeper than 1:20 and total slope height > 5 m.

Finding areas with slope of 1:20 (5% slope) could be done with the slope function. But I can't figure out an easy way to filter these areas to only include areas with slope height over 5 meter. I.e. the vertical height form start of slope to top should be at least 5 meters.

Anyone have any ideas or thoughts on this problem?

Background: The criteria are to identity possible land slide areas (quick clay), so it's already clipped to only include areas of old marine sediments. https://www.ngu.no/en/topic/quick-clay-and-quick-clay-landslides

  • What do you mean by slope height? Commented Jan 21, 2018 at 23:19
  • What have you tried? The question is indeed interesting and I guess there are exmaples of that already. One approach could be to extract stream from a subset of the terrain model with slope >= 20%. Then select the streams longer than the target head of fall (5m) divided by the slope. I have not heard of an accumulative fall function (with elevation units), but I am looking fordward to hearing of it
    – Marco
    Commented Jan 22, 2018 at 9:07
  • I can see here a good example of the limitations of the square grid compared with the hexagonal grid. The length of the distance between cells matters when the accumulate fall (or slope height) is the target. The diffrerence between the length horizontal or vertical length compare with the diagonal one is huge for these purposes (sqrt(2)=1.41!!)
    – Marco
    Commented Jan 22, 2018 at 9:18
  • Roberto Ribeiro - I edited the question to clarify "slope height" Commented Jan 22, 2018 at 11:32
  • Marco - I havent tried anything yet for finding the height. First I tried to figure it out with paper and pen, the searching the net, without success. My guess is that this is an rather normal problem in the field of geotechnics and hydrology, but that my wording of the problem, and my search, is wrong... Now I will try diffrent use of stream networks with SAGA hydrology plugin. Commented Jan 22, 2018 at 11:41

2 Answers 2


This can be done in a few ways, but using QGIS specifically, the best way I can think of is using Map Algebra. The idea is to first get all areas with a slope above your desired threshold, then calculate the Zonal Statistics for it. The step-by-step is as follows:

  1. Generate slope with Raster -> Analysis -> DEM -> Slope (input raster must be in projected CRS)
  2. Create mask raster with only your chosen threshold. Go to Raster -> Raster Calculator, and evaluate a new raster with [slope raster] >= [threshold] in the expression field. This is a binary raster.
  3. Merge smaller zones into larger ones. This is done so you don't end up with a 1-2 pixel zone (which can happen, since slope is calculated on a per-pixel basis). To do so go to Processing Toolbox -> Sieve, and decide a minimum pixel count for areas.
  4. Now you'll need to identify the different areas (they all have a value of 1 in your mask raster). To do so, first go to Raster -> Convert -> Poligonize, chosing a field name for your values column. Then, with this layer in edit mode, go to Field Calculator and update your value field with if([value field] > 0, '$id', [value field]). This way each zone will get a specific number associated with it, and the zones with gentle slopes remain as 0. Finally, rasterize this polygon layer again, attributing the field value to pixel value (the QGIS Rasterize tool may not work properly, if so consider using either the GDAL or the SAGA Rasterize tools in the Processing Toolbox).
  5. Now, call the r.univar GRASS function from the Processing Toolbox, pass to it your original DEM (the one used to calculate the slope), and the rasterized raster from the previous step as a mask. The output will be a text file with statistics for each zone. They look like this:

    zone 1 
    total null and non-null cells: 31
    total null cells: 0
    Of the non-null cells:
    n: 31
    minimum: 579
    maximum: 645
    range: 66
    mean: 603.581
    mean of absolute values: 603.581
    standard deviation: 16.2218
    variance: 263.147
    variation coefficient: 2.68759 %
    sum: 18711

    repeated for each zone. The only info you want is zone number, minimum and maximum. Format this table into a CSV where each line is zone,minimum,maximum.

  6. Import this CSV into QGIS by going to Layer -> Add Layer -> Add Delimited Text Layer. Then, do a join with your polygon layer from step 4, joining by the zone number.
  7. Finally, create a new field and calculate maximum - minimum. Whichever features are above 5 in this resulting field will be your areas of interest.


As per user ThingumaBob's comment, one can simplify this procedure by using the Zonal Statistics tool that comes with QGIS, and which works with a vector layer as zones input.

As such, from step 4, after polygonizing the raster, one would go to Processing Toolbox -> Zonal Statistics, and enter the DEM as input raster and the polygon zones layer as input mask. The output is the same polygon layer, with extra fields for the calculated stats (hence, the end of step 6).

  • I learned during my tries that difference the slopes form each other was as big a problem as finding the relative heights. But #4 in your answer is such a great way to do it! Looking forward to try this out! Commented Jan 26, 2018 at 0:32
  • ...couldn´t you just use zonal statistics to get the same result? polygonize as in #4 (just the conversion step), immediately run zonal statistics (min, max) on the DEM and add the new field with max - min?
    – geozelot
    Commented Jan 26, 2018 at 16:56
  • @ThingumaBob That's actually an easier solution, indeed! I remember the zonal statistics tool used to have an abnormal behaviour in past versions, so I didn't even think to check it this time. I'll add this to the answer. Commented Jan 26, 2018 at 20:37
  • This answer with Zonal Statistics have solved my initial question, and I was able to produce a map of possible land slide areas, or at least a staring point for a map. Now I need to work on the pre- and post-filtering (Example; road side ditch, steep sides, and over five meters relative height from start of road to end og road a few km later). Thanks!! Commented Jan 29, 2018 at 12:07

If you are looking to calculate your slope height you could try "Relative Heights and Slope Positions" (SAGA) available in QGIS. I never used it, but it seems to be the right tool for that.

Take a look at this question to see some info. SAGA tool 'Relative Heights and Slope Positions' - What do results tell me?

Now to filter your regions:

Use Raster Calculator with your height and slope images. The formula on the calculator should be something like this: Slope Image * (Height Image > 5)

This will give an image of your slope in wich places with height smaller than 5 will be 0

You can also make a mask image using only "Height Image > 5" as a formula

  • Thanks for the filter cookbook! The "Relative Heights and Slope Positions" (SAGA) might be the right tool, but so far I have not been able to solve the problem using it. I never thought it should be such a problem to formulate the one line "real word" criteria into functions! Commented Jan 24, 2018 at 23:40

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.