Offline Reverse Geocoding in Python

拜拜、爱过 提交于 2019-12-30 03:32:06

问题


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.


回答1:


Have you considered using OpenStreetMap? You can download the whole database (the "planet") or one of the extracts if you just need a specific area. Afterwards you can filter out all addresses and use the resulting data for your geocoding. There are several search engines for OSM available, the most popular one is Nominatim. It is used on the main website and can do both geocoding and reverse-geocoding. So it might be a good starting point for your task.




回答2:


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'}]

Internally it uses locations from the geonames database and a k-d tree to find the nearest neighbour.



来源:https://stackoverflow.com/questions/18803509/offline-reverse-geocoding-in-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!