1

I have recently moved to using GRASS for GIS within R and I would like to extract values of a raster dataset that overlap with polygons (i.e. something like 'extract' in the raster package of R).

I can perform my task for spatial points as follows:

execGRASS("r.what", flags="n", map="temperatureRaster", Sys_input=paste(x, y, site, sep=' '), separator=",", intern=TRUE)

However, I have spatial polygons not spatial points. Eventually, I would like to calculate a mean value for all raster cells whose centroid overlaps with each spatial polygon.

2

I would suggest using the GRASS module v.rast.stats as it "calculates univariate statistics from a raster map based on a vector map and uploads statistics to new attribute columns".

  • Yes, that looks like what I need. However, I think I would first like to get the vector map of all the points (raster cell centroids) inside each of my polygons. Do you know how I could do that? – tsutsume Jan 16 '18 at 11:17

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.