nyc geoclient restful api的python包装器
python-geoclient的Python项目详细描述
python geoclient
使用python调用restfulNYC Geoclient API。
简介
这个库为使用NYC Geoclient API提供了一个python接口。它是更新和维护的nyc_geoclient分叉。
为了使用库,您必须首先使用NYC Developer Portal注册一个应用程序,以获取应用程序密钥和ID。
安装
您可以使用以下命令安装python geoclient:
$ pip install python-geoclient
或者您可以克隆此目录并:
$ python setup.py install
快速启动
一旦您的应用程序注册到DoITT,使用api就很简单:
fromgeoclientimportGeoclientg=Geoclient('my app ID','my app key')
您可以使用API:
中记录的任何可用方法g.address(100,'Gold st','MN'){u'uspsPreferredCityName':u'NEW YORK',u'fireCompanyType':u'E',u'fromLionNodeId':u'0015445',u'cooperativeIdNumber':u'0000',u'dotStreetLightContractorArea':u'1',u'lionBoroughCodeForVanityAddress':u'1',u'zipCode':u'10038',u'fireCompanyNumber':u'006',u'communityDistrict':u'101',u'firstStreetNameNormalized':u'GOLD STREET',u'boroughCode1In':u'1',u'latitude':40.71035225065372,u'longitude':-74.00400739046181,...}
地理编码错误
当geoclient api返回错误代码时,python geoclient将引发一个GeoclientError
。有时会返回更多信息,在这种情况下,异常将有一个result
字典。
fromgeoclientimportGeoclientErrortry:g.address(125,'wort st',1)exceptGeoclientErrorase:print(e)# 'WORT STREET' NOT RECOGNIZED. THERE ARE 010 SIMILAR NAMES.print(e.result['streetName1'])# WORTH SQUARE
文件
使用库的Python Geoclient documentation详细信息。
api紧跟DoITT documentation(需要帐户/登录)。
运行测试
python setup.py test
贡献
如果你看到一个问题或想贡献,拉请求是受欢迎的。
许可证
疯牛病。