[GIS] How does Zonal Statistics work exactly

layersqgisrastersagazonal statistics

I'm a bit confused on how the zonal statistics tools work in QGIS (either the 'Zonal Statistics' tool under the Raster tools from the QGIS geoalgorithms toolbox or the 'Raster statistics from polygons' tool under the SAGA Vector<->Raster tools).

Basically I have a raster map layer and some small polygons in a separate layer. I want to assign each polygon the value of the raster below. In case a polygon overlaps multiple raster cells, I just want to have the maximum.

Yet the output doesn't make any sense and I can't get behind the reasoning of those results (which are obviously not the maximum of the underlain raster cell):

enter image description here

Any ideas what I'm doing wrong or what I didn't consider yet? The results with the python API in qgis.analysis.QgsZonalStatistics() (according to this question here) are much better, but it does only offer count, mean and sum…but for some reason no max or min.

Best Answer

Update as April 2018 and QGIS 2.18

The current version of Zonal Statistics Plugin can provide:

Count: to count the number of pixels
Sum: to sum the pixel values
Mean: to get the mean of pixel values
Median: to get the median of pixel values
StDev: to get the standard deviation of pixel values
Min: to get the minimum of pixel values
Max: to get the maximum of pixel values
Range: to get the range (max - min) of pixel values
Minority: to get the less represented pixel value
Majority: to get the most represented pixel value
Variety: to count the number of distinct pixel values

Original answer

In short, this approach with QGIS, as far as I'm aware is not possible to view the raster pixel maximum as a result. Only the count, mean and sum. I've provided some resources that covers this.

Here is the doc page for the plugin Zonal Statistics Plugin

With the icon_zonal_statistics Zonal statistics plugin, you can analyze the results of a thematic classification. It allows you to calculate several values of the pixels of a raster layer with the help of a polygonal vector layer (see figure_zonal_statistics). You can calculate the sum, the mean value and the total count of the pixels that are within a polygon. The plugin generates output columns in the vector layer with a user-defined prefix.

Also, this QGIS Tutorial Sampling Raster Data using Points or Polygons provides a sample data to achieve zonal statistics return. I've included screenshot they provide as a example of their workflow and results.

Enable the Zonal Statistics Plugins. This is a core plugin so it is already installed. See Using Plugins to know to how enable core plugin

enter image description here

enter image description here

enter image description here

Once the processing finishes, select the counties layer. Use the Identify tool and click on any county polygon. You will see three new attributes added to the layer: ZS_count, ZS_mean and ZS_sum. These attributes contain the count of raster pixels, mean of raster pixel values and sum of raster pixel values respectively. Since we are interested in average temperature, the ZS_mean field will be the one to use.

enter image description here