Using QGIS, I have a single-band raster with with multiple counties. I have reclassified the pixels into 2 categories, using a singleband pseudocolor, based on their value ( > or < 3800), corresponding to non-forest or forest land.

How do I calculate the proportion of pixels that is in each of the 2 categories, in each county?

I have a lot of images over a lot of years so I would prefer to not take the route the I figured out - converting to shp, exporting as csv, sorting csv and calculating percentages in Excel.

Raster with several counties Table of Contents

  • it's not entirely clear from your question if your "multiple counties" are available as a polygon layer, can you confirm this?
    – dmci
    Jan 14, 2016 at 12:47

2 Answers 2


Zonal Statistics https://docs.qgis.org/2.2/en/docs/user_manual/plugins/plugins_zonal_statistics.html

Or just extract the rasters by the polygons Clip raster layer with *raster* mask layer in QGIS

It has been while since I used the zonal statistics but I remember it give a count value.

enter image description here

  • Yes. I had discovered the Zonal Statistics plugin and had it working nicely - giving me a summary of each county. The problem is that it doesn't give me values per category, ie forested vs non-forested (the ones shown in my TOC). Any way to get it to show me # of pixels/category?
    – user65148
    Jan 13, 2016 at 1:15
  • Thanks makes sense for nominal data, I may be mixing the arc and qgis zonal functions. just make two rasters and give each pixel a value of 1 and then it is the sum in this table or the count. Forested= 1 in one and unforested = 1 in the other. right? Jan 13, 2016 at 2:04
  • That doesn't quite make sense to me. How do I give each pixel a 1?
    – user65148
    Jan 13, 2016 at 2:27
  • Im saying if all pixels are 1 or 0 then the sum of the pixels is the count. So <3800 to 1. Jan 13, 2016 at 2:33

I know this is an old question, but I wanted to give input as this is something I just had to do. I have a raster with a single band and unique values representing land cover usage and polygons representing historical wildfires. I used the Zonal Histogram tool in QGIS 3.8: enter image description here to add columns with each value and the count of pixels that contain that value within the wildfire footprint (i.e. i want to get % land use within fire footprint): enter image description here

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.