访问openstreepmap overpass api的python包装器
overpy2的Python项目详细描述
访问overpass api的python包装器。
查看documentation以查找其他信息。
功能
- 查询立交桥API
- 分析json和xml响应数据
- 其他辅助功能
安装
要求:
支持的Python版本:
- python=3.4
- pypy和pypy3
安装:
$ pip install overpy
示例
其他示例可以在documentation和examples目录中找到。
importoverpyapi=overpy.Overpass()# fetch all ways and nodesresult=api.query(""" way(50.746,7.154,50.748,7.157) ["highway"]; (._;>;); out body; """)forwayinresult.ways:print("Name: %s"%way.tags.get("name","n/a"))print(" Highway: %s"%way.tags.get("highway","n/a"))print(" Nodes:")fornodeinway.nodes:print(" Lat: %f, Lon: %f"%(node.lat,node.lon))
助手
帮助器方法可用于提供对常用请求的轻松访问。
importoverpy.helper# 3600062594 is the OSM id of Chemnitz and is the bounding box for the requeststreet=overpy.helper.get_street("Straße der Nationen","3600062594")# this finds an intersection between Straße der Nationen and Carolastraße in Chemnitzintersection=overpy.helper.get_intersection("Straße der Nationen","Carolastraße","3600062594")
许可证
在麻省理工学院出版(更多信息请参见许可证)