简体   繁体   中英

Correct way to use GeoPy Nominatim

I'm new on programing, and I'm using a programing tutorial which said that to use geopy like this:

import pandas, os, geopy
from geopy.geocoders import Nominatim

GeoLocator = Nominatim()

but after the last line I'm getting this error:

/usr/local/lib/python3.7/site-packages/geopy/geocoders/osm.py:143: UserWarning: Using Nominatim with the default "geopy/1.17.0" user_agent is strongly discouraged, as it violates Nominatim's ToS https://operations.osmfoundation.org/policies/nominatim/ and may possibly cause 403 and 429 HTTP errors. Please specify a custom user_agent with Nominatim(user_agent="my-application") or by overriding the default user_agent : geopy.geocoders.options.default_user_agent = "my-application" . In geopy 2.0 this will become an exception. UserWarning

My question is, how should I change my code to fix this error?

nom = Nominatim(user_agent="http")你必须提到你的 useragent(HTTP) 它只是关于 IP 地址

You should specify a user_agent. The Nominatum service runs on donated servers which have limited capacity, so specifying a user-agent field allows Open Street Map to track more easily who is using their service. See here for a more detailed answer .

If you don't they may block your IP address from accessing the service as that would be a violation of their terms of service.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM