用Python实现地理编码

1、百度地图
安装

pip install geocoder

import geocoder
g = geocoder.arcgis([40.050934, 116.30079], method='reverse')
print g.address
print g.city
print g.state
print g.country

输出的结果

None
北京市
北京市
CHN
>>> 

2、查看IP

import geocoder
g = geocoder.ip(‘199.7.157.0’)
print g.latlng
print g.city
g = geocoder.ip(‘me’)
print g.latlng
print g.city

输出的结果

[43.6934, -79.4857]
Toronto
[39.9289, 116.3883]
Beijing

查询一个城市的空间包围盒

import geocoder
g = geocoder.arcgis(u"盐城")
g.bbox

输出:{'northeast': [33.421558, 120.161276], 'southwest': [33.349558, 120.089276]}

转载:[http://mp.weixin.qq.com/s?__biz=MzAxMjUyNDQ5OA==&mid=2653552196&idx=1&sn=6f817a1dfb9046d14961bf9f0e8ee0a7&chksm=806dd0f9b71a59ef0457acc565818ecf278a3e6eb09344fc3f063aa11ab02cd4f29792e9e466&scene=0#rd]

你可能感兴趣的:(python,python,百度地图)