[GIS] Summing pixel values within polygon zone in QGIS

polygonqgisraster

I have two layers: a raster layer and a vector layer (polygon). I can see the values of the raster pixels but I don't know how to combine them with information from the polygon layer. More specifically, I would like to :

  1. sum values of all pixels within a the borders of a polygon
  2. count the number of pixels with a specific value within the
    borders of a polygon

Can anybody help and advise on how to do this in QGIS?

Best Answer

Use to be that you had to use v.rast.stats in the GRASS Plugin, but now you can use the inbuilt Zonal Statistics in the Raster menu.

You have a polygon layer loaded and the raster. You run the menu item.

that will answer part a) of your question.

v.rast.stats and other tools will give you more detailed output, but probably a simple workflow for b) is to extract each polygon (use the Raster|Extraction|Clipper menu) and then run a histogram on each. Depends on the structure of your data, how often you have to do it, etc.

Related Question