Python中的离线反向地理编码 [英] Offline Reverse Geocoding in Python
问题描述
我正在编写一个Python脚本,该脚本将纬度和经度传递给模块,并执行反向地址解析功能以返回该位置的地址.我一直在使用Google的PyGeoCoder来执行此操作,但是它需要访问Internet.我需要与PyGeoCoder类似的东西,但需要开源且完全脱机.
I am writing a Python script that passes a latitude and longitude to a module and performs a reverse geocode function to return the address of the location. I have been using Google's PyGeoCoder to do this, but it requires access to the Internet. I am needing something similar to PyGeoCoder but open sourced and completely offline.
推荐答案
我创建了一个模块来完全做到这一点: https ://bitbucket.org/richardpenman/reverse_geocode
I created a module to do exactly that: https://bitbucket.org/richardpenman/reverse_geocode
>>> import reverse_geocode
>>> coordinates = (-37.81, 144.96), (31.76, 35.21)
>>> reverse_geocode.search(coordinates)
[{'city': 'Melbourne', 'code': 'AU', 'country': 'Australia'},
{'city': 'Jerusalem', 'code': 'IL', 'country': 'Israel'}]
在内部,它使用地名数据库中的位置和一棵k-d树来查找最近的邻居.
Internally it uses locations from the geonames database and a k-d tree to find the nearest neighbour.
这篇关于Python中的离线反向地理编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!