1

I have a database contains 5000 building approx, I want to locate them through its address, so I use GeoPy like this:

def getLalo(address):
    geolocator = Nominatim()
    location = geolocator.geocode(address)
    if location == None:
        return [0,0]
    return [location.latitude,location.longitude]

bmk['latitude'], bmk['longitude']= bmk.apply(lambda row: getLalo(row['full_address']), axis=1)

However, seems like I got GeocoderServiceError: HTTP Error 429: Too Many Requests

How do I avoid this? thx!

stat0619
  • 45
  • 3
  • 9

1 Answers1

0

When you send requests in short of time, rate-limiting must be taken into account.

You will receive: Too Many Requests 429 HTTP error or timing out.

Try with RateLimiter

from geopy.extra.rate_limiter import RateLimiter
geocode = RateLimiter(geolocator.geocode, min_delay_seconds=1)

reference https://geopy.readthedocs.io/en/1.16.0/#usage-with-pandas

Mia Chang
  • 121
  • 2