【问题标题】:Geopy Error with Reverse Geocoding反向地理编码的 Geopy 错误
【发布时间】:2013-04-20 17:09:55
【问题描述】:

我正在使用 Geopy。我收到以下代码错误。

我使用与https://code.google.com/p/geopy/wiki/ReverseGeocoding 相同的代码

from geopy import geocoders

g = geocoders.GeoNames()
(place, point) = g.geocode("Palo Alto, CA 94306")
print place
>> "Palo Alto, US 94306"
print point
>> (37.418008999999998, -122.127375)

(new_place,new_point) = g.reverse(point)
print new_place
>> 3998 Ventura Ct, Palo Alto, US 94306 
print new_point
>> (37.417850000000001, -122.12793000000001)

在打印点之前工作正常。 g.reverse(point) 发生错误

Traceback (most recent call last):
  File "<interactive input>", line 1, in <module>
  File "C:\Python27\lib\site-packages\geopy\geocoders\base.py", line 9, in reverse
    raise NotImplementedError
NotImplementedError

有什么建议吗?

【问题讨论】:

标签: python geocoding reverse-geocoding geopy


【解决方案1】:

geopy 0.97 提供反向地理编码。您可以从https://github.com/geopy/geopy 下载并安装新版本的 geopy 或克隆 git 存储库。

git clone https://github.com/geopy/geopy.git
cd geopy
sudo python setup.py install

如果你想下载安装windows,你可以从https://github.com/geopy/geopy/archive/release-0.97.zip获取最新版本

解压和

cd geopy-release-0.97
python setup.py install

将查询地理定位到地址和坐标:

>>> from geopy.geocoders import GoogleV3
>>> geolocator = GoogleV3()
>>> address, (latitude, longitude) = geolocator.geocode("175 5th Avenue NYC")
>>> print(address, latitude, longitude)
175 5th Avenue, New York, NY 10010, USA 40.7410262 -73.9897806

找到一组坐标对应的地址:

>>> from geopy.geocoders import GoogleV3
>>> geolocator = GoogleV3()
>>> address, (latitude, longitude) = geolocator.reverse("40.752067, -73.977578")
>>> print(address, latitude, longitude)
77 East 42nd Street, New York, NY 10017, USA 40.7520802 -73.9775683

--

【讨论】:

    猜你喜欢
    • 2021-01-26
    • 2015-07-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-31
    • 1970-01-01
    相关资源
    最近更新 更多