我正在编写一个 Python 脚本,它将纬度和经度传递给模块并执行反向地理编码功能以返回该位置的地址。我一直在使用 Google 的 PyGeoCoder 来执行此操作,但它需要访问 Internet。我需要类似于 PyGeoCoder 但开源且完全离线的东西。
最佳答案
我创建了一个模块来做到这一点: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'}]
在内部,它使用 geonames 数据库中的位置和 k-d 树来查找最近的邻居。
关于python - Python中的离线反向地理编码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18803509/