NYC Geoclient REST API的Python绑定
项目描述
# NYC Geoclient Python绑定
REST [NYC Geoclient API][api]的Python绑定。
[api]: http://developer.cityofnewyork.us/api/geoclient-api-beta
### 使用方法
首先,您需要在与[NYC开发者门户][portal]注册应用程序,并确保您勾选了应用程序对Geoclient API的访问权限。注意应用程序的ID和密钥。您将无法使用ID和密钥,直到[DoITT][]批准您,这可能需要几天时间,您将在收到电子邮件时得到通知。仪表板上没有您状态的指示,但所有请求都将返回403。
[portal]: https://developer.cityofnewyork.us/ [DoITT]: http://www.nyc.gov/html/doitt/html/home/home.shtml
您可以使用pip install安装nyc-geoclient。它依赖于[requests][]库。
[requests]: http://docs.python-requests.org/en/latest/index.html
$ pip install nyc_geoclient
一旦您的应用程序获得DoITT的批准,使用API就很简单
>>> from nyc_geoclient import Geoclient >>> g = Geoclient('my app ID', 'my app key')
所有REST端点都受支持。
>>> g.address('1500', 'Madison Ave', 'Manhattan') {u'assemblyDistrict': u'68', u'boardOfElectionsPreferredLgc': u'1', u'boePreferredStreetName': u'MADISON AVENUE', u'boePreferredstreetCode': u'12539001', u'boroughCode1In': u'1', u'censusBlock2000': u'2000', u'censusBlock2010': u'3003', u'censusTract1990': u' 168 ', u'censusTract2000': u' 168 ', u'censusTract2010': u' 168 ', u'cityCouncilDistrict': u'08', u'civilCourtDistrict': u'06', u'coincidentSegmentCount': u'1', ...>>> g.intersection('atlantic ave', 'nevins st', 'Brooklyn') {u'assemblyDistrict': u'52', u'boroughCode1In': u'3', u'censusTract1990': u' 39 ', u'censusTract2000': u' 39 ', u'censusTract2010': u' 39 ', u'cityCouncilDistrict': u'33', u'civilCourtDistrict': u'01', u'communityDistrict': u'302', u'communityDistrictBoroughCode': u'3', u'communityDistrictNumber': u'02', u'communitySchoolDistrict': u'15', u'congressionalDistrict': u'08', u'crossStreetNamesFlagIn': u'E', u'dcpPreferredLgcForStreet1': u'01', u'dcpPreferredLgcForStreet2': u'01', u'dotStreetLightContractorArea': u'3', ...
##### 错误
在地理编码器无法正常工作时,它仍将返回一个字典。您必须查看message的值以了解发生了什么。
>>> g.intersection('atlantic ave', 'nevins st', 'manhattan') {u'boroughCode1In': u'1', u'censusTract1990': u' ', u'censusTract2000': u' ', u'censusTract2010': u' ', u'crossStreetNamesFlagIn': u'E', u'firstBoroughName': u'MANHATTAN', u'firstStreetNameNormalized': u'ATLANTIC AVENUE', u'geosupportFunctionCode': u'2', u'geosupportReturnCode': u'11', u'message': u"'ATLANTIC AVE' NOT RECOGNIZED. THERE ARE NO SIMILAR NAMES", u'secondStreetNameNormalized': u'NEVINS ST', u'streetName1In': u'ATLANTIC AVE', u'streetName2In': u'NEVINS ST', u'workAreaFormatIndicatorIn': u'C'}
消息通常非常有帮助。
### 文档
请查看[Python文档][],以获取使用绑定的详细信息,该绑定紧随[DoITT文档][](需要账户/登录)。
[Python文档]: https://nyc-geoclient.readthedocs.org/ [DoITT文档]: http://developer.cityofnewyork.us/api/geoclient-api-beta
### 许可证
BSD。
项目详情
nyc_geoclient-0.0.2.tar.gz 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | d4c664908bc80e3b7a6dc49b3c96624eb25420734346e7d768fde97bf66738cf |
|
MD5 | 96d7b8d9945afa65d28cec8919dd9d67 |
|
BLAKE2b-256 | 48bc26cf7e4a139f1b319a9328e0a769a680f248d8ee11ba018c47263fc2c8e1 |