# Calculating continuous raster representing land cover proportion from categorical raster using QGIS?

I have a raster (5 x 5 m resolution) representing land cover. Each cell contains a integer value (from 1 to 10) representing a total of ten land cover classes (e.g. 1-forest; 2-agricultural areas; 3-urban areas;(...)10-scrublands).

Based on this categorical land cover raster, I would like to produce ten rasters with a resolution of 10 x 10 m representing the proportion of each land cover class per cell. In another words, I would like to produce a raster representing the proportion of forest, another raster representing the proportion of agricultural areas, etc.

This figure explains exactly what I want to do (for illustrative purposes, I only accounted for 3 classes in the figure). I have been looking for similar questions in the internet, but usually people had slightly different questions (e.g. calculate land cover proportion within a polygon).

Does anyone know how to do this in QGIS?

I haven't got access to QGIS on this laptop, but here's roughly how I would approach it:

1. Take your 5m land use raster and use `Raster calculator` to produce a new boolean raster that has a value of 1 for a given class, and 0 for all other values. For example for the forest class: `5m_landuse = 1`
2. Use the `r.resamp.stats` tool from the `GRASS GIS/Raster` toolbox to aggregate the new boolean raster to 10m cells. Select the output resolution to 10m and the aggregation method to `average`. For every 10m pixel, this will take the average of the four contributing 1s (forest) and 0s (non-forest) in your 5m pixels, which ends up being equal to a proportion (e.g. average of 1, 1, 1 and 0 = 0.75).

You will need to repeat this for each of your ten land use classes, but this can probably be automated using the `graphical modeller` tool. Good luck!

I agree on the method proposed in the first answer (first convert to one binary raster per class, take take the average). However, I think that it would be slighly faster with the gdal tools (from raster > conversion if you don't like command lines).

``````gdal_translate in_binary_5m.tif out_proportion_10m.tif -r average -outsize 50% 50%
``````

Remark -outsize 50% 50% set the output at a 50% resolution (equivalent to 1/50% (= double) the size of the pixels)