I have a raster stack of climate data from which I would like to extract values based on a set of point coordinates. Some of these points are just outside the raster extent, so I'd like to apply a buffer (c. 1500 m) to calculate the mean of the bordering raster cells. Yet, for the rest of the points I'd like to extract the exact value without applying the buffer. Is there an argument that I can add to the raster::extract
function (or a similar function) to do so or do I need to split my dataset first?
1 Answer
I think splitting is the solution. There's no argument in extract
in either raster
or terra
(and you should try and use terra
) to do this, and I tried a couple of experiments with geometry columns that are mixes of point and polygon and the extract
function isn't happy.
You might also want to use the exact_extractr
package for polygon-raster extractions (it is very fast and uses partial pixel calculations where polygons cut pixels).