I have lat longs and want R to return a column of the neighborhood tabulation area for each point;
lat long NTA 40.79127 -73.96484 Morningside Heights 40.72622 -73.98380 East Village 40.79196 -73.96809 Upper West Side
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It only takes a minute to sign up.
Sign up to join this communityI have lat longs and want R to return a column of the neighborhood tabulation area for each point;
lat long NTA 40.79127 -73.96484 Morningside Heights 40.72622 -73.98380 East Village 40.79196 -73.96809 Upper West Side
You are looking for an spatial join, after converting your lat-longs to a spatial object. This is done easily with package sf
, replace the filenames with yours on the following code:
library(sf)
library(dplyr)
lat_longs = read.csv(latlongs.csv) %>%
st_as_sf(coords = c("longitude_column", "latitude_column")) %>%
st_set_crs(4326) # coordinate reference system is lat-long
NTA = read_sf("nta_polygons.shp")
lat_longs_NTA = lat_longs %>% st_join(NTA)