Search code examples
pythongeolocationgeopandasgeopy

Tracing latitude and longitude using Python library


Can anyone guide me with the best location tracker ,to trace latitude and longitude using Python library. I am volunteering for not-for-profit ( Wild Life rescue) and eagerly trying to trace the exact location.

My file has 2800 entries to trace the latitude and longitude

My code :

    lat_long=[]
    import geopandas as gpd
    from geopy.geocoders import ArcGIS
    geolocator = ArcGIS()
    for address in new_wordlist:
        location = geolocator.geocode(address)
        loc={'latitude':location.latitude,'longitude':location.longitude}
        lat_long.append(loc)

Coding is working fine, however getting the below error. And only able to receive 900 entries

Error : HTTPSConnectionPool(host='geocode.arcgis.com', port=443): Max retries exceeded with url: /arcgis/rest/services/World/GeocodeServer/findAddressCandidates?singleLine=John+Oldham+Park+Western+Australia&f=json&maxLocations=1 (Caused by ReadTimeoutError("HTTPSConnectionPool(host='geocode.arcgis.com', port=443): Read timed out. (read timeout=1)"))

Please suggest the best practise to run the code smoothly..


Solution

  • It does not feel that it is coming from your code but rather from a limitation imposed by the website you are querying. I would suggest to put a time.sleep(1) in each of your iteration. If it still does not work, it means that you have a hard cap on the number of queries you can do per day.