By GeoEki


2017-09-11 15:57:37 8 Comments

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.

2 comments

@whyzar 2017-09-11 16:21:44

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

@dbaston 2018-05-03 15:59:00

As of QGIS 3.0 (possibly earlier, I'm not sure), the following statistics are available:

  • Count
  • Sum
  • Mean
  • Median
  • Standard deviation
  • Minimum
  • Maximum
  • Range
  • Minority
  • Majority (mode)
  • Variety
  • Variance

Related Questions

Sponsored Content

2 Answered Questions

[SOLVED] "Zonal" Statistics Using Line Features

0 Answered Questions

How does Zonal statistics handle pixels that are on border of polygon?

2 Answered Questions

0 Answered Questions

How to display min and max pixel from Zonal Statistics?

  • 2018-03-20 20:58:09
  • Francisco Sánchez Acosta
  • 44 View
  • 2 Score
  • 0 Answer
  • Tags:   qgis zonal-statistics

0 Answered Questions

QGIS Zonal Statistics for polygons is missing results?

2 Answered Questions

[SOLVED] Zonal Statistics for multiple rasters

5 Answered Questions

[SOLVED] How to calculate raster statistics for polygons?

1 Answered Questions

1 Answered Questions

1 Answered Questions

[SOLVED] Extract results from zonal statistics

Sponsored Content