使用python实现地理位置查询经纬度

地理编码工具geocoder

地理编码工具geocoder,不同厂商的服务整合统一起来
地理编码

import geocoder
g = geocoder.google("1403 Washington Ave, New Orleans, LA 70130")
g = geocoder.arcgis(u"北京市海淀区上地十街10号")
g.latlng

输出为

[29.9287839, -90.08421849999999]

也可以查看完整的geojson

g.geojson

逆地理编码

#可以换成arcgis的服务试试
g = geocoder.google([29.9287839, -90.08421849999999], method='reverse')

print g
print g.address
print g.city
print g.state
print g.country

geocoder 的功能不止于此,它还可以查IP(包括自己的)

g = geocoder.ip('199.7.157.0')
print g.latlng
print g.city
g = geocoder.ip('me')
print g.latlng
print g.city

你可能感兴趣的:(python)