Dear all, I am trying to match a large number of coordinates (attached) sub-national regions using GADM shapefile.
Coordinates: https://drive.google.com/file/d/1PUsi4d0wP7hB6Aps6UmpXsnIPSD3I1sT/view?usp=sharing Shapefile: https://drive.google.com/drive/folders/1DxyygjQNeg2GIS9doaFM8yM2LvBYZi8E?usp=sharing This is the code I am using; ### library(data.table) library(ncdf4) library(rgdal) library(raster) library(tidyverse) ## Read coordinates coords <- read.csv("coords.csv") ## Read shapefile world <-readOGR(dsn = "/gadm36_levels_shp", layer = "gadm36_2") ## Convert to spatial points pts <- coords coordinates(pts) <- ~lon+lat ## Provide the same CRS to the coordinates as the shapefile proj4string(pts) <- proj4string(world) ## Use over function to match coordinates to polygons pts_district <- over(pts, world)$NAME_1 ### However, less than 20% of the coordinates are matched to a polygon. What am I doing wrong? Any help will be greatly appreciated. Regards, Milu [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.