跳转到主要内容

Python包装器,用于访问OpenStreetMap Overpass API

项目描述

一个用于访问Overpass API的Python包装器。

请查看文档以获取更多信息。

Latest Version License https://github.com/DinoTools/python-overpy/actions/workflows/ci.yml/badge.svg?branch=master https://coveralls.io/repos/DinoTools/python-overpy/badge.png?branch=master

功能

  • 查询Overpass API

  • 解析JSON和XML响应数据

  • 额外的辅助函数

安装

需求

支持的Python版本

  • Python >= 3.6.2

  • PyPy3

安装

$ pip install overpy

示例

更多示例可以在文档examples目录中找到。

import overpy

api = overpy.Overpass()

# fetch all ways and nodes
result = api.query("""
    way(50.746,7.154,50.748,7.157) ["highway"];
    (._;>;);
    out body;
    """)

for way in result.ways:
    print("Name: %s" % way.tags.get("name", "n/a"))
    print("  Highway: %s" % way.tags.get("highway", "n/a"))
    print("  Nodes:")
    for node in way.nodes:
        print("    Lat: %f, Lon: %f" % (node.lat, node.lon))

辅助

提供了辅助方法,以便轻松访问常用请求。

import overpy.helper

# 3600062594 is the OSM id of Chemnitz and is the bounding box for the request
street = overpy.helper.get_street(
    "Straße der Nationen",
    "3600062594"
)

# this finds an intersection between Straße der Nationen and Carolastraße in Chemnitz
intersection = overpy.helper.get_intersection(
    "Straße der Nationen",
    "Carolastraße",
    "3600062594"
)

许可证

在MIT许可下发布(见LICENSE获取更多信息)

项目详情


下载文件

下载适合您平台的文件。如果您不确定选择哪个,请了解有关安装包的更多信息。

源分布

overpy-0.7.tar.gz (48.6 kB 查看哈希值)

上传时间 源代码

构建分发

overpy-0.7-py3-none-any.whl (14.8 kB 查看哈希值)

上传时间 Python 3

由...