Home

Awesome

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, beautify

# 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)
print(beautify(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.

Contributing

Setup the development environment

Windows

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

Linux

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

Unit tests

Run all the tests with:

python -m pytest ./tests