Search code examples
pythonpython-3.xgeolocationopenstreetmapnominatim

How to get the latitude and longitude from the address in python quickly?


I have used the code for finding the latitude and longitude from the given address:

     locator = Nominatim(user_agent="myGeocoder")  # holds the Geocoding service, Nominatim
     geocode = RateLimiter(locator.geocode, min_delay_seconds=0.00000000000000000000000000000000000000000000000000000000000000000000000000001)
    data['MBR_location'] = data['MBR_Full_Address'].apply(lambda x: geocode(x))
     data['Prov_location'] = data['Prov_Full_Address'].apply(lambda x: geocode(x))

But it takes so much time to produce the latitude and longitude. For example, in this way, it needs 3 hours for getting the latitude and longitude from only 10k ID. Is there any way to get the results faster way? Thanks in Advance!


Solution

  • I guess it takes so long because you are using OSM's public Nominatim instance and the usage policy only allows one request per second. So either switch to a different Nominatim instance or install your own local Nominatim server.