[GRASSLIST:7798] Raster statistics using vectors

Jose Gomez-Dans jgomezdans at gmail.com
Fri Aug 5 03:21:36 EDT 2005


Hi!
I have a number of raster files, and a number of shape files (vectors)
with a large number of fields. I have imported both into GRASS without
much problem. I want to calculate some statistics for each of the
polygons. For example, I want to output for each polygon a number of
columns and the mean, mode and standard deviation for all the raster
cells that fall within said polygon.

Up to now, I have used a program in C which takes rasterised versions
of the vector map (where cells are given the value of one of the
columns). The rasters are all coincident, and it's straightforward to
do this.

I would however like to accomplish this task in GRASS using scripts,
and shortcircuiting the need to generate intermediate files. I guess
that this can be done rasterising the shapes and using mapcalc and
r.stats, but I was wondering whether there's a simple way of
accomplishing this, as it is a pretty standard operation.

Many thanks for the help!
José




More information about the grass-user mailing list