1

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?

2

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.

  • oh excellent. Would I need my rasters to be in an equal area projection? I could not have my rasters in degrees while doing this. Right? – I.Stirs Jun 10 '16 at 14:07
  • It is almost always preferable to have your data in a distance based projection however, no it is not necessary. In this example the reason the buffer distance is so large is that the default projection units in the dummy raster I created is degrees. – Jeffrey Evans Jun 10 '16 at 14:27

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.