nyc geoclient rest api的python绑定
nyc_geoclient的Python项目详细描述
#纽约地理客户端python绑定
其余部分的python绑定[nyc geoclient api][api]。
[api]: http://developer.cityofnewyork.us/api/geoclient-api-beta
###用法
首先,您需要向[NYC Developer]注册一个应用程序 portal][portal],并确保选中geoclient api的访问权限 为了申请。注意应用程序的id和密钥。你不会的 在[doitt][]批准之前可以使用id和密钥–这可能需要 几天之后,你会收到一封邮件。没有 在仪表板上显示您的状态,但所有请求都将返回403。
[portal]: https://developer.cityofnewyork.us/ [DoITT]: http://www.nyc.gov/html/doitt/html/home/home.shtml
您可以安装pip。这取决于[请求][]库。
[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')
所有其余端点都受支持。
>>> 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', ...
#####错误
如果地理编码器不工作,它仍然会返回一个dict。 必须查看消息的值才能查看发生了什么。
>>> 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 documentation]: https://nyc-geoclient.readthedocs.org/ [DoITT documentation]: http://developer.cityofnewyork.us/api/geoclient-api-beta
###许可证
疯牛病。