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.