I have a SpatialPointsDataFrame
with thousands of datapoints in a relatively small geographic area. The points are grouped around regions of physical measurements and are hence irregularly spaced:
plot(old)
I'd like to resample these data onto a coarser grid that is sparsely populated so as not to overextrapolate observations. Each point in the grid grid should take on the value of the closest point in old
--- unless there are no data within (say) a 500m radius, in which case the grid point in new
should take on the value of NA
.
ggg <-raster(crs = old@proj4string,
ext = extent(old@bbox),
resolution = 1000)
gg <- as(pppp, 'SpatialGrid')
plot(gg)
I have played around with creating an empty SpatialGrid
object as shown above and using over()
, but I get a vector of NAs. I assume that's because the points in the grid do not precisely align with my data.
I am currently trying to see if there's a way to do it with aggregate
but no dice so far. Note that I don't want to average all values in each grid cell---instead, I want to use the nearest single observation to each grid cell center / point.
Can anyone point me in the right direction?