Approaches for IDW and nearest neighbours
To apply the closest neighbour method, we used terra::voronoi()
and stayed with {terra}
.
For the IDW & nearest neighbour method, gstat::gstat()
is used to define the interpolation algorithm.
However the book applies the gstat
result to sf
points, then converting back to a SpatRaster
:
- extract cell center coordinates from
grid
, createsf
points object, then filter bymap
- then use the
predict()
method with thegstat
andsf
points objects- advantage:
gstat::gstat()
is aware ofsf
geometries
- advantage:
- then apply
terra::rasterize()
to the resulting points with predicted values