Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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
add comment

3 Answers 3

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: grass.osgeo.org/gdp/html_grass64/databaseintro.html –  maning Jul 14 '11 at 11:46
add comment

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 r.to.vect 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
add comment
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
1  
i don't think its limited to small rasters, check this: starspan.casil.ucdavis.edu/doku/doku.php?id=lfs. 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
add comment

Your Answer

 
discard

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.