Rasterize SpatVect (points) with buffer around SpatRaster

Viewed 25

I have a SpatVect consisting of points and I want to rasterize them into a SpatRaster with a given resolution. Is there a way of specifying a function taking in the points that are within a buffer of each raster cell?

Many thanks Joao

-- Update -- Maybe a figure would help understand what I'm after with my question. The red square will have to be run over the center of each pixel to calculate some statistics using the ovelaying points. Apologies for the clumsy question, but I hope the figure is clear enough...

enter image description here

1 Answers

The approach you take seems to depend on what result you're looking for from the above and the relationship they have with each other.

library(terra)

`terra::buffer(` # both SpatVectx/SpatRastery, to distance in 'm'
`terra::buffer(` # that is meaningful
#take Rasty to SpatVecty 
`terra::as.polygons(`, #then 
`z<-terra::intersection(SpatVectx, SpatVecty)`

then back to SpatRastz? terra::mask or crop, might also be useful, again depending on where things are going next.

Related