[GIS] Alternatives to Zonal Statistics which include partial pixels (QGIS)

polygonpyqgisqgisrasterzonal statistics

The task I want to complete is essentially exactly what the Zonal Statistics plugin for QGIS aims to achieve: gives statistics about the values of a raster layer in areas defined by polygons.

However, the way Zonal Statistics seems to work is that it treats a pixel as either 'in' or 'out' of the polygon ('in' if more than half the pixel is in?). Due to limitations of my data, my raster pixel size (30m) is close to the size of the polygons I am using (100m radius circles) so those edge effects become very important. I would therefore like an alternative method which calculates the same statistics, but based on the actual area of each pixel contained within the polygon.

One option I have thought of would be to crop the raster to match my polygons, polygonize the raster, export the values and areas of the generated polygons, and carry out the calculations separately, but that seems like a lot of effort compared to a tool like Zonal Statistics. This method may also be complicated by the fact that some of my polygons overlap.

Best Answer

I think you hit on your best option, which is to convert the raster to a vector and then intersect the result with your polygon layer.

As a way of explanation regarding the frustration you're experiencing with Zonal Statistics (and actually this will also apply to your idea of cropping or "clipping" the raster), there is no alternative way for this to operate; a single raster cell has to be either in or out.

You also mention that some of your "zones" (ie. polygons) overlap. This will also negate results of a standard Zonal Statistics tool since most of those explicitly mention that they do not account for this and recommend running the tool over each feature separately if this is the case.

Related Question