Right now I have a GeoJson File and the following function using shapely:
It takes in a coordinate and returns the neighborhood name
def get_neighb(lat, lon):
"""Input Latitude and Longitude, Returns Neighborhood Name"""
point = Point(lon, lat)
found = False
for feature in geo_data['features']:
polygon = shape(feature['geometry'])
if polygon.contains(point):
return(feature['properties']['neighborhood'])
found = True
if found is False:
return('NA')
# Initialize list
tn = ['']*data.shape[0]
for i in range(len(tn)):
tn[i] = get_neighb(data.latitude[i], data.longitude[i])
This works, but it is really slow, any thoughts on how I could speed it up, currently running it on 4,000,000 row.