One possible way is to generate a raster MASK file from the vector data and, using the mask for each polygonal area and R, calculate statistics that way. Although, honestly, I don’t know if that would be faster or not.
Another possibility is something like this (snippit from a GRASS script in a Linux environment), that we have used where speed is critical:
···
--
Thomas E Adams
National Weather Service
Ohio River Forecast Center
1901 South State Route 134
Wilmington, OH 45177
EMAIL: [thomas.adams@noaa.gov](mailto:thomas.adams@noaa.gov)
VOICE: 937-383-0528
FAX: 937-383-0033
On Tue, Jun 21, 2011 at 6:10 PM, Frederico Mestre
<mestre.frederico@gmail.com> wrote:
Hello,
The vector I've got is a grid 10x10 km, but it has some small irregular
shapes, do you think it would be adequate for raster calculation?
Since you want to retrieve statistics from raster maps for vector
areas, the resolution of the raster maps should be used for the
computations. I think both v.rast.stats and v.rast.stats2 align the
region to the raster resolution. It can happen that areas smaller than
a single cell are skipped, because that level of detail is not present
in the raster map.
And I need to calculate a large number of variables, for a large geographic
area, using this vector and underlying rasters.
Use v.rast.stats2. It is much faster for vector maps with many areas
and also has fewer bugs than v.rast.stats. v.rast.stats and
v.rast.stats2 are both shell scripts, so you can just download
v.rast.stats2 and replace the existing v.rast.stats if installation
via g.extension fails.