【问题标题】:deprecation warning:using nominatim with the default弃用警告:使用 nominatim 和默认值
【发布时间】: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()

我正在使用上面的代码将字符串(地址)转换为坐标。请帮我解决上述警告,或者如果有其他方法可以执行相同的过程,请告诉我。

【问题讨论】:

标签: python python-3.x geopy


【解决方案1】:

我的问题是,当我在命令提示符下运行上述程序时,它没有提供字符串的位置(坐标)。它在警告处停止。

“可以在此处找到 Nominatim 地理编码器的正确调用:geopy.readthedocs.io/en/1.22.0/#module-geopy.geocoders”-@KostyaEsmukov

上述调用方法对我也不起作用。 它会抛出相同的警告并且不会继续。

【讨论】:

    猜你喜欢
    • 2013-04-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-07
    • 2017-05-04
    相关资源
    最近更新 更多