I have two datasets: one with 300k + grid points on a map and the other has 75 district centroids. Both datasets have long/latitude of grid points/district centroids. I am trying to match each grid point to each district, such that the grid point's distance to the district centroid <= 100 km. How can I do this in R?
I tried geosphere packages:
merged %>%
distGeo(c(merged$longitude, merged$latitude), c(geo$centroid_longitude, geo$centroid_latitude))
I also tried distm
command but it does not work either.