Skip to main content

Overpass Forge: a query builder for the Overpass query language

PyPI latest version License Documentation status CI tests

An object-oriented model to build Overpass queries in Python. Primarly intended to generate complex queries in Python. Checkout the documentation.

Install

Requires Python 3.10 or higher. Install with:

pip install overpassforge

Example

from overpassforge import Areas, Nodes, Ways, build

# Find both cinema nodes and ways in Bonn, which
# are at most 100m away from bus stop nodes

bus_stops = Nodes(within=Areas(name="Bonn"), highway="bus_stop")
ways = Ways(around=(bus_stops, 100.0)).where(amenity="cinema")
nodes = Nodes(around=(bus_stops, 100.0)).where(amenity="cinema")
result = ways + nodes
result.out("meta")

query = build(result, beautify=True)
print(query)

Output:

area["name"="Bonn"]->.set_0;
node(area.set_0)["highway"="bus_stop"]->.set_1;
(
  way(around.set_1:100.0)["amenity"="cinema"];
  node(around.set_1:100.0)["amenity"="cinema"];
);
out meta;

Features

List of currently implemented features, based on the Overpass QL wiki.

  • Settings: all except augmented-difference between dates (adiff)
  • Block statements
    • union, difference, intersection
    • For-each loop (foreach)
    • Block statements if, for, complete, retro, compare
  • Standalone statements
    • out
    • Item (implicit)
    • Recurse up (<) and down (>)
    • Recurse up relations (<<) and down (>>)
    • Query for areas (is_in)
    • Statements timeline, local, convert, make
    • The Query Statement (node, way, rel, area only)
    • The Query Filter
    • Map way/relation to area (map_to_area)
  • Filters
    • By tag (has-kv)
    • Bounding box
    • Recurse (n, w, r, bn, bw, br)
    • Recurse (way_cnt, way_link)
    • By input set (.setname)
    • By element id
    • Relative to other elements (around)
    • By polygon (poly)
    • newer
    • By date of change (changed)
    • By user (user, uid)
    • By area (area)
    • Area pivot (pivot)
    • Conditional query filter (if:)

Contributing

Setup the development environment

Windows

python -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install -r requirements.txt
pip install -e .

Linux

python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
pip install -e .

Unit tests

Run all the tests with:

pytest

Metadata

Release files for overpassforge 0.4.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for overpassforge 0.4.4
File Size Uploaded
overpassforge-0.4.4.tar.gz 30.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for overpassforge 0.4.4
File Interpreter ABI Platform
overpassforge-0.4.4-py3-none-any.whl Python 3 none any Details

Total release size: 49.3 kB

Release files / overpassforge-0.4.4.tar.gz

Download URL overpassforge-0.4.4.tar.gz
Size 30.8 kB
Tags Source
SHA-256 checksum
How to use checksums
675eaa53fa7fdee5ab1b24073a9e24f2aa451558914a0d9a8b737fa6ec1f1afd
BLAKE2b-256 checksum
How to use checksums
c19d7ede9fafbbdb560fc57248ccf8eb2ceb8445ed483016f9fe008ffe7002de
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / overpassforge-0.4.4-py3-none-any.whl

Download URL overpassforge-0.4.4-py3-none-any.whl
Size 18.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b89918a5ddb0da5477c1b670164601bfa7595eea37ce9fb77d8b55ebcce30993
BLAKE2b-256 checksum
How to use checksums
2a1f73f97bc4c181351720e5d51c0bcf3f165bb73933b3bc13246298bfcc389f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release history Release notifications | RSS feed

This release

0.4.4 This release

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page