我正在编写一个Python脚本,将纬度和经度传递给一个模块,并执行反向地理编码函数以返回该位置的地址。我一直在使用Google的PyGeoCoder来完成这项任务,但它需要访问互联网。我需要类似于PyGeoCoder的开源且完全离线的解决方案。
我创建了一个模块来实现这一点:https://github.com/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树来查找最近的邻居。
coordinates = (-37.81, 144.96)
然后reverse_geocode.search(coordinates)
,但是我收到了一个错误信息:TypeError: 'int' object is not iterable
。 - stackoverflowuser2010