1

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

1

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)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.