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 have a vector layer (polygon) and a raster layer. The raster layer holds values for height above bald earth in a field called "value". I'd like the vector layer to inherit either the mean or the mode values from raster cells falling within the boundaries of each polygon. I run this command in grass:

v.rast.stats nameofpolygon raster=nameofraster colprefix=height

The result is a polygon populated with all the fields you'd expect but containing all null values within these fields.

  • I did receive a warning that some polygons are missing centroids at the beginning of the output.
  • The raster and vector layers are within the same Grass Mapset and do occupy the same geographic space.
  • I did set the region to contain both features prior to running v.rast.stats

Thanks in advance for you help!

(2011/05/10)UPDATED DETAILS: I created an entirely new GRASS Location & Mapset; Loaded both my raster and polygon features to the same Mapset; Ran v.centroids on the polygons; Ran g.region.raster; Calculated univariate statistics (v.rast.stats) from the raster based on the vector; Double checked that the raster does actually contain values, and it does in a field titled "value". The statistics are still returning NULL values. I've tried this through GRASS, GRASS-gui, and QGIS gui.

share|improve this question
    
I ran this same command (v.rast.stats) through the QGIS interface. The results were the same. I also again verified the raster and vector occupy the same geographic space and that the GRASS region contains the area in question. I'm going to add any missing centroids to the polygons through GRASS tools and try again to generate statistics. –  Paul May 8 '11 at 16:09
    
Note to self: Always check region limits... –  nickves Nov 14 '12 at 18:32
add comment

3 Answers 3

up vote 0 down vote accepted

Try to change db.connect to SQLlite. I had the same problem and this worked for me.

share|improve this answer
    
Thanks, I'll give it a try. –  Paul Jul 15 '11 at 14:34
add comment

Rasters have got a lot better in QGIS 1.7, I can run v.rast.stats from the GRASS Tools in the QGIS GUI. QGIS is much more friendly and if you have any inadvertent projection errors etc they are more obvious than is the case with GRASS. Despite your efforts to check, I suspect you have these sorts of problems. You should be able to point QGIS at the GRASS Mapset you have already created.

share|improve this answer
    
I have viewed my data in QGIS and also GRASS and the raster and vector do in fact occupy the same space. They are also within the same GRASS mapset. –  Paul May 3 '11 at 5:20
add comment

Did you have any luck with running v.rast.stats from within QGIS via the GRASS Plugin? At the dialog in that tool, at the top to the right of the dropdown for the raster map "name of raster map to calculate statistics from" there is a toggle button "use region of this map". Perhaps that helps. Also it was suggested to me to run "g.region raster" when trying to resolve the same problem in GRASS standalone, in the QGIS/GRASS plugin that command is available as g.region.multiple.raster. I believe this is worth a try.

ciao

share|improve this answer
    
Thanks for the QGIS advice. I did set the region based on the raster using the g.region command in GRASS as you suggest. –  Paul May 8 '11 at 14:56
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.