[GIS] How to extract values from a raster stack within overlapping buffers

bufferextractoverlapping-featurespointr

In R, I have a raster stack with 6 variables. I would like to extract the mean and maximum value of each variable at 300 coordinates within a 500m buffer radius and a 1km buffer radius.

In ArcGIS 10.2 there are problems extracting variables from buffers if there is any overlap. Is this a problem in R?

If not, how do you make buffers around a point in R?
And how would I extract the mean and maximum value at the two scales surrounding each point?

Best Answer

In your case, it is not necessary to create polygon buffers for your points. The raster::extract function has a buffer argument that will do exactly what you are after.

library(raster)
r <- raster(ncol=36, nrow=18)
  r[] <- 1:ncell(r)
xy <- SpatialPoints(cbind(-50, seq(-80, 80, by=20)))

extract(r, xy, buffer=1000000, fun=mean)

For future reference the rgeos::gBuffer function will allow you to create buffers, and if the by.id=TRUE argument is used the buffers will not be dissolved into a single feature class. These buffers can be passed to extract withour issues of overlapping polygons.

Related Question