4

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

  • 1
    Can you provide the output of g.list rast and the full syntax of your v.rast.stats? – maning Apr 11 '12 at 1:42
  • when I type 'g.list' into the 'Modules list' no module appears. – Becky Apr 11 '12 at 12:16
  • Please post which GRASS version you use. – markusN May 18 '12 at 23:05
6

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

1

Or use the version 1.4 of the LecoS plugin for QGIS, if zonal statistics and GRASS fail you. You can find the plugin via the downloader, but you must have the scientific library "Scipy" installed.

See an example use-case on my blog,which deals with exactly your problem. Hope it helps :-)

1

For QGIS 3.0 and onward, the Zonal Statistics Plugin suggested by @Thomas is included in the Processing Toolbox. So instead of looking for it in the Plugins, just look for the

Zonal Statistics function from the Raster Analysis tools in QGIS.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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