Reputation: 45
I'm using the geopy library with the Nominatim API to geocode locations in a Python script. However, I keep getting this error:
geopy.exc.GeocoderTimedOut: Service timed out
this is my code:
from geopy.geocoders import Nominatim as NT
import folium
geo_locator = NT(user_agent="geoapiExercises")
place_1 = "Yemen"
location_1 = geo_locator.geocode(place_1)
user_map1 = folium.Map(location=[location_1.latitude, location_1.longitude], zoom_start=15)
user_map1.save("map.html")
i checked my internet connection, but I still get the timeout error intermittently and I increased the timeout parameter, but it still times out occasionally
i want to create the base map by using this code but keep getting error message. how can i handle or prevent this timeout error message?
Upvotes: 1
Views: 106
Reputation: 11
The GeocoderTimedOut
error typically occurs when the Nominatim service takes too long to respond. This can be due to a variety of reasons such as network issues, server load, or the Nominatim service being overwhelmed.
To handle or prevent the timeout error, you can use a retry mechanism in your code.
Upvotes: 1