[GIS] How to calculate the average value of a raster within polygons

grassqgis

I am using the GRASS plugin in QGIS. I am trying to calculate the average value of a raster dataset within a set of polygons.

I have created a new mapset and have imported both the vector and raster layers into the GRASS mapset.

I am now trying to calculate the set of statistics using the v.rast.stats tool.

It starts to run and then comes up with the error an error occurred while converting vector to raster and then 'raster map not found'.

v.rast.stats raster=secant_grass@zonalstats
vector=plots_grass@zonalstats
colprefix=g/Applications/GRASS-6.4.app/Contents/MacOS/scripts/v.rast.stats:
line 190: 632 Segmentation fault v.to.rast in="$VECTORFULL"
out="${VECTOR}_$TMPNAME" layer="$GIS_OPT_LAYER" use=cat type=area
--quiet An error occurred while converting vector to raster Raster map not found  nothing removed Finished with error

Any help would be greatly appreciated.

Regards

Best Answer

Use the zonal statistics plugin in QGIS - this gives you the count, sum and mean of a raster within a given polygon.