微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

使用Python检索街道地址的美国邮政邮政编码

使用Python检索街道地址的美国邮政邮政编码最有效的方法是什么?这有可能吗?

优选地,包括与某种远程API调用相对的本地数据库的东西.

提前感谢您提供的任何帮助.

解决方法:

可能是一个开始:
The Zip Code Database Project

googlemaps – Google Maps and Local Search APIs in Python

GoogleMaps.geocode(query, sensor='false', oe='utf8', ll='', spn='', gl='')

Given a string address query, return a dictionary of information
about that location, including its
latitude and longitude.
Interesting bits:

>>> gmaps = GoogleMaps(api_key)
>>> address = '350 Fifth Avenue New York, NY'
>>> result = gmaps.geocode(address)
>>> placemark = result['Placemark'][0]
>>> lng, lat = placemark['Point']['coordinates'][0:2]
# Note these are backwards from usual
>>> print lat, lng
40.6721118 -73.9838823
>>> details = placemark['AddressDetails']['Country']['AdministrativeArea']
>>> street = details['Locality']['Thoroughfare']['ThoroughfareName']
>>> city = details['Locality']['LocalityName']
>>> state = details['AdministrativeAreaName']
>>> zipcode = details['Locality']['PostalCode']['PostalCodeNumber']
>>> print ', '.join((street, city, state, zipcode))
350 5th Ave, brooklyn, NY, 11215

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐