Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to compute some statistics of the pixels of a given raster that are coincident to the polygons of a vector file. Is there a simple and effective way to do this in Quantum GIS or similar?

share|improve this question

You can use the GRASS plugin within QGIS that has the module v.rast.stats

Calculates univariate statistics from a raster map based on vector polygons and uploads statistics to new attribute columns.

There was also a mention of the zonal statistics in qgis-trunk last month. I'm not sure if this was added in QGIS 1.7.

share|improve this answer
I was trying this v.rast.stats but i had this: Processing data ... Updating the database ... ERROR: This should not happen: wrong return type in parsing. dbmi: Protocol error ERROR: Error while executing: – vascobnunes Jul 14 '11 at 9:36
this is usually an error with the dbase driver. Can you post the full syntax and output of your v.rast.stats and v.db.connect? Some readings on GRASS db management: – maning Jul 14 '11 at 11:46

I don't know why you are doing that but the number of pixels will depend of your raster resolution and I'm not sure the method proposed by manning will convert automatically the pixels into area (but you should check!).

Vectorizing your raster file and calculating the area overlaps will give you a result in the defined units (meters, miles, or whatever).

if you want to proceed that way, then GRASS will help you. See function.

share|improve this answer
I think is is more what i need, cause v.rast.stats first converts the vector to raster with the inputed resolution, and that doesn't work for me. If I convert the raster to poly and intersect the two vector files, then i would need to aggregate and sum the areas per raster category for each polygon. How do i do this in GRASS? – vascobnunes Jul 13 '11 at 14:32
see v.overlay the v.db.* functions into the doc! – simo Jul 13 '11 at 21:15
up vote 2 down vote accepted

I did the job easily with StarSpan

share|improve this answer
Interesting link, thanks. From that page, though, it's impossible to tell what this software is capable of or how it does it. Could you perhaps say a little more about how you obtained these zonal stats? Is there a particular utility or command to look for? – whuber Jul 14 '11 at 13:21
This StarSpan only does this raster on vector analysis. Basicaly it strips the raster into a text/csv file where it includes also attributes from the coincident polygons. Then it has the ability to aggregate and produce statistics for the polygons. For example, polygon with id=1, avg_raster_value=4.5, mode_raste_value=4...and so on. Its very simple and works fine. – vascobnunes Jul 14 '11 at 13:33
Thanks! (+1). It sounds like it's limited to small rasters, though: that conversion to text is highly inefficient. – whuber Jul 14 '11 at 13:38
i don't think its limited to small rasters, check this: why not give it a try. – vascobnunes Jul 14 '11 at 13:52
Thanks: it's good to see that this software supports the much larger file sizes that are needed. – whuber Jul 14 '11 at 13:54

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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