# Calculating percent overlap of Raster Layers using QGIS?

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.

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

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. ## (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 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%)) • 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. 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