Python中的离线反向地理编码 [英] Offline Reverse Geocoding in Python

查看:305
本文介绍了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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆