QGIS – Calculate Average Raster Value within Polygons by Type Using QGIS

qgisrastervectorzonal statistics

I have seen How to calculate the average value of a raster within polygons?, which helps me a bit but not completely.

I have a raster of 16000 by 12000 (country-size) and a vector which indicates different types of landuse. I would like to get the average value of the raster per type of landuse (Forest, Recreation, Roads, Farmlands, etc.)

The post linked above says to use the 'Zonal Statistics' tool. Unfortunately I can't seem to get this to work for a layer with a lot of different polygons.

I could create separate layers for each landuse type and use that for the analysis, but I rather have something quicker.

Maybe an option is also to rasterize the vector and then use the 'Raster Layer Zonal Statistics'tool?

Best Answer

The solution would be to Dissolve (Processing Toolbox -> Vector Geometry) your polygon layer using the landuse as the "Dissolve field(s)". By doing this you will have one polygon layer per landuse type. Then you can apply the Zonal Statistics (Processing Toolbox -> Raster Analysis) which is going to give you a single value (for the selected parameter to compute, mean for instance) for each landuse.