【发布时间】:2020-06-17 13:20:55
【问题描述】:
webmap.py:5: DeprecationWarning: Using Nominatim with the default "geopy/1.22.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.
nom=Nominatim()
当我在使用命令提示符编译的记事本中运行它时会显示上述警告,但是当我使用 Jupiter notebook 时会显示警告,但会继续并显示结果。这是我的代码:
from geopy.geocoders import Nominatim
def map_coordinates():
address = str(input("enter the street name and city seperated by :"))
nom = Nominatim()
c = nom.geocode(address)
return (c.latitude, c.longitude)
z, x = map_coordinates()
我正在使用上面的代码将字符串(地址)转换为坐标。请帮我解决上述警告,或者如果有其他方法可以执行相同的过程,请告诉我。
【问题讨论】:
-
您尝试遵循警告内容的具体问题是什么?如果这样更清楚,可以在文档中找到相同的消息:geopy.readthedocs.io/en/1.22.0/#geopy.geocoders.Nominatim。可以在这里找到正确调用 Nominatim 地理编码器:geopy.readthedocs.io/en/1.22.0/#module-geopy.geocoders
标签: python python-3.x geopy