I am trying to calculate two zonal statistics: count and variety.
My raster is a produce of r.raster.area with 4399 groups of pixels within a matrix of no-data values (which are coded as 65535).

My vector layer holds seven hand created polygons, which I have checked for validity, both with the built-in Validity Check algorithm and visually.
As I need Variety, the only tool I can use is the QGIS Zonal statistics tool in the Processing Toolbox. When I run the analysis, I get correct values for Count, but Variety is always 0 (which is impossible, as all the polygons hold many different values).

Could this be a problem with the high number of unique values (4399)?

  • 1
    I suspect this is a bug. When you need Variety measure, will you also select either Minority or Majority, or both of them along with Variety?
    – Kazuhito
    Commented Nov 19, 2020 at 4:54
  • 1
    Together with minority and majority I get a value for variety !=0, without 0. Commented Nov 19, 2020 at 10:21

1 Answer 1


You need to also either Minority or Majority when asking for Variety, as pointed out by @Kazuhito and @Jochen Schwarze. It works smoothly when done so.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.