I am working with the New York City taxi data set. The data set has columns including datetime, pickup lat/lon, dropoff lat/lon etc. Now I want to reverse geocode the lat/lon to find the borough/neighborhood. I came across geopy
and found that something like this worked perfectly:
from geopy.geocoders import Nominatim
geolocator = Nominatim()
borough = []
loc = ['40.764141, -73.954430', '40.78993085, -73.9496098723']
for l in loc:
sub = str(geolocator.reverse(l))
borough.append(sub.split(', ')[2])
borough
## ['Upper East Side', 'East Harlem']
This is perfect, and exactly what I want. However, my dataset has a few million rows, and since this is an online API, it is not feasible. Are there any better ways to accomplish this?