r <- rast(ncol=100, nrow=100, crs="local", xmin=0, xmax=50, ymin=0, ymax=50)
set.seed(100)
x <- runif(25, 5, 45)
y <- runif(25, 5, 45)
z <- sample(25)
xyz <- cbind(x,y,z)
x <- interpNear(r, xyz, radius=5)
p <- vect(data.frame(xyz), geom=c("x", "y"))
v <- voronoi(p)
plot(x, col=rainbow(25))
lines(v)
# plot(v, col=rainbow(25)); points(p)
Run the code above in your browser using DataLab