I am just wondering if it’s possible to do batch reverse geocoding (from coordinates to NY borough) for free?

Hello! I am a grad student currently working on a NY covid mobility tracing project. I am just wondering if it’s possible to do batch reverse geocoding (from coordinates to NY borough) for free. I have around (500,000 coordinates). I noticed there are some websites can do it but the price tag on them is way out of my range. Thank you

Thank you!!

@QIZHEN_DING If you’re comfortable using R, you can do this with the sf package. I can share sample code if it would help.

Thank you for the feedback!! I will look into that.

Hi @QIZHEN_DING - Depending on what types of addresses these are, and what you’re trying to accomplish, this may be a great use case for Placekey!

The Placekey API generates free, universal location identifiers based on an address, coordinate pair, or POI name. It also has a bulk append option that can handle your 500k+ rows.

There’s a quick start guide here: Getting Started with Placekey.io

And a bunch of tutorials here: Tutorials

And there’s more info about how Placekey works here: How it Works

Once you’ve appended Placekeys, SafeGraph has a Places API available (in beta) that will let you query those placekeys to derive all other attributes of those places: Places API

Hope this was helpful! Let @Pranav_Thaenraj_SafeGraph know if you have any other questions?

If you’re having any issues with the process, you can reach out to @John_Votta_SafeGraph for help. Thanks!

Thank you for the speedy response. I have came up with my own solution. R has a special package called sf, which allow users to batch reverse -geo code. Here’s a sample

library(sf)
sf <- sf::st_read("https://raw.githubusercontent.com/blackmad/neighborhoods/master/new-york-city-boroughs.geojson")
file_paths<- fs::dir_ls("/Users/dir")
file_paths
file_contents<- list()
#################
#####for loop to read in files 
for (i in 1:8){
  # read in 2 csv files just to test 
  data1<- read.csv(file=file_paths[[i]])
  data1
  file_name<- strsplit(file_paths[i],'/')
  file_name
  f_name<-tail(file_name[[1]], 1)
  f_name
  ######### reverse geo-encodeing from coord to location
  longitude = c(data1$lng)
  latitude = c(data1$lat)
  x <- data.frame(longitude,latitude)
  x
  sf_x <- sf::st_as_sf(x, coords = c("longitude", "latitude"))
  st_crs(sf_x) <- st_crs(sf)
  res <- st_within(sf_x, sf)  ## return the indexes of sf that sf_x are within
  sol <- sapply(res, function(x) as.character(sf$name[x]))
  sol1 <- c(sol)
  data1$geo_loc<-sol1 
  data1$geo_loc = as.character(data1$geo_loc)
  ############
  ###### write the new content into the new csv file 
  write.csv(data1,paste0("/Users/dir/new-",f_name))
}```

Nice! Glad it worked. I usually use st_join() to just append a polygon/geography column to the dataframe of points