I've got a grid/raster in R that is represented as centroids of the grid instead of polygons. I am trying to merge that with points.
library(sf) nc <- st_read(system.file("shape/nc.shp", package="sf")) grid_10000 <- st_make_grid(nc, cellsize = c(10000, 10000)) %>% st_sf(grid_id = 1:length(.),grid_prop = sample(c("one","two"),length(.),replace=T)) grid_centroids <- st_centroid(grid_50) %>% cbind(st_coordinates(.)) pts <- st_sample(nc, size = 5) %>% st_sf # I can join the points easily like this joined <- st_join(pts,grid_10000)
Now without grid_10000, how could I see which point gets which parameter simply based on the centroids. A method that could make a grid from the centroids would be best. The distances are unknown too. And 'sf' solution would be preferred.