2

I have two raster layers, a DEM and a land use layer. The DEM layer is divided into discrete intervals (e.g. 100-200 m). I am trying to figure out how to calculate the percentage of each elevation interval that is allocated to each type of land use.

For example, calculating the percentage of the area between 100m and 200m that is agricultural. It seems like this should be straight forward, but I have not found a good method. I am using QGIS 2.18, and would prefer to keep using the same program.

1 Answer 1

2

We can tackle this in two steps.

  1. Get new raster showing area of overlap between pixels of interest
  2. Get statistics for areas of overlap

(1) Get Area of overlap between pixels of interest:

Using SAGA Raster Calculator from the processing toolbox, we can extract out pixels which meet our criteria.

In this case: get land use data for pixels that are in elevation range 100m-200m

-Main input layer: Elevation Raster

-Additional layers: Land cover Raster

Formula: ifelse(eq(a, 1), ifelse(eq(b, 1),(a*b), 0), 0/0)

(where elevation layer has value of 1 (assigned pixel value for 100-200m) AND landcover has a value of 1 (assigned pixel value for 'Agriculture'), set output pixel value to 1 (if not 1 then set pixel value to null)

This will output a raster which contains pixel value of 1 for areas where elevation and landcover raster pixel values were 1.

enter image description here

(2) Get statistics for areas of overlap:

Use r.stats to compute % of pixels for each pixel value for the raster genertated in step 1.

-Number of fp...: 2

-Print APPROXIMATE percents...: X

-Suppress reporting of any NULLs...: X

-Read fp map as integer...: X

stats and outputs results[2]

Tested Example:

-Hatched area = elevation raster,

-Colored area = land use raster

-Black and white Area = output from step 1 (white area = pixel value 1, (~41.17%)) Working Example

4
  • Thank you for the cogent reply! I am still running into problems though. When I run the raster calculator, I get the following error message Dec 21, 2017 at 2:42
  • AttributeError: 'module' object has no attribute 'TYPE_RASTER' Dec 21, 2017 at 2:45
  • Are you using the 'SAGA Raster Calculator'? If not, Go to Processing > Toolbox and from there search 'Raster Cal', you will see two options, pick the one under SAGA.
    – Cushen
    Dec 21, 2017 at 3:59
  • Thanks, I am using the Saga Raster Calculator. I get the same message with every formula I input, even simple ones (e. g. eq(a,1). Dec 21, 2017 at 15:30

Your Answer

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

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