Hey, I would like to know if any one knows how to find all the road names in the location - Nairobi. The segment geometry data only has road names of a smaller portion of the area. Could there be any way the names of these other roads be found?
#################################### Road information ######################################
def get_address_by_location(latitude, longitude, language="en"):
"""This function returns an address as raw from a location will repeat until success"""# build coordinates string to pass to reverse() function
coordinates = f"{latitude}, {longitude}"
# sleep for a second to respect Usage Policy
time.sleep(1)
try:
return app.reverse(coordinates, language=language).raw
except:
return get_address_by_location(latitude, longitude)
def get_road_by_location(latitude, longitude):
address = get_address_by_location(latitude, longitude)
return address['address']
# launch only one time and save to file. Works 2 hours for collecting inforoad_list_for_locations = []for i in tqdm(range(df.shape[0])): road_list_for_locations.append(get_road_by_location(df.latitude[i], df.longitude[i]))
Hope it helps!!! Good luck!!!
Thanks. I'll check it out right away.
Edit: It worked better than I expected. I added an additional line of code to make it run:
app = Nominatim(user_agent='myGeocoder')
Great👍. You're welcome.