Fast OpenStreetMap reachability, routing, and isochrones from Python, powered by Rust.
Project description
Graphways
Graphways is a Rust-powered Python library for fast local reachability,
routing, and isochrone analysis on OpenStreetMap road networks. It builds a
reusable SpatialGraph once, then runs repeated network-aware queries directly
in process without deploying a routing server.
Graphways is designed for workflows that need the street network as a practical analysis primitive: accessibility studies, urban analytics, site selection, agent-based simulations, notebook exploration, and application backends that need low-latency local graph operations.
Installation
Install the Python package from PyPI:
pip install graphways
Or add the Rust crate to Cargo.toml:
[dependencies]
graphways = "0.4.0"
To build the Python extension from source, install Rust and maturin, then run:
maturin develop
Usage
import graphways as gw
origin = (38.9097, -77.0432)
destination = (38.8977, -77.0365)
graph = gw.SpatialGraph.from_place(
"Washington, DC",
network="walk",
max_dist=10_000,
)
isochrones = graph.isochrone(origin, minutes=[10, 20, 30])
route = graph.route(origin, destination, max_snap_m=100)
reachable = graph.reachable(origin, minutes=15, max_snap_m=100)
print(route.duration_s, route.distance_m)
route_geojson = route.to_geojson()
iso_geojson = isochrones[0].to_geojson()
SpatialGraph is the central object. Reachability and network-time prism
queries return lightweight graph views over the parent graph, so inspection and
GeoJSON export do not copy the full road network.
reachable.nodes()
reachable.edges_geojson()
reachable.route(origin, destination)
prism = graph.prism(
origin=origin,
destination=destination,
max_minutes=45,
stop_minutes=10,
buffer_minutes=5,
)
possible_stops = prism.nodes()
slack_polygon = prism.slack_polygon(min_slack_s=5 * 60)
Routes, snap diagnostics, and isochrones return structured Python objects.
Call .to_geojson() when you need serialized GeoJSON for mapping or data tools.
Features
- Build reusable walking, biking, driving, and custom-access OSM road graphs.
- Load from Overpass XML, existing OSM XML strings, or local OSM PBF files.
- Query nearest nodes with an R-tree spatial index.
- Compute reachability over the road network from a single origin.
- Generate isochrones with one graph search and triangulated contour extraction.
- Route point-to-point with distance, duration, geometry, and cumulative times.
- Build network-time prisms for "what can I visit between A and B?" analysis.
- Export nodes, edges, routes, POIs, and isochrones as GeoJSON.
Documentation
Start with the quickstart, then see the Python graph API and Rust API notes.
The examples directory and documentation show common workflows:
- building graphs from places, XML, and PBF files
- computing walking and driving isochrones
- routing between coordinates
- querying reachable nodes and graph views
- working with POIs and GeoJSON output
Network Services
SpatialGraph.from_place(...), gw.geocode(...), and POI fetching use public
OpenStreetMap services by default. Graphways sends a descriptive User-Agent,
rate-limits Nominatim geocoding requests, and retries transient 429 / 5xx
responses.
For production workloads, local mirrors, or stricter service policies, configure the service layer with environment variables:
GRAPHWAYS_OVERPASS_URL=https://overpass-api.de/api/interpreter
GRAPHWAYS_NOMINATIM_URL=https://nominatim.openstreetmap.org/search
GRAPHWAYS_USER_AGENT="your-app/1.0 contact@example.com"
GRAPHWAYS_CACHE_DIR=/path/to/graphways-cache
Use SpatialGraph.from_pbf(...) when you need fully offline graph construction.
Performance
Graphways is optimized for repeated local queries over the same area. Graph construction is paid once; subsequent reachability, routing, and isochrone queries reuse the in-memory graph and spatial index.
The benchmark suite compares steady-state graphways queries against NetworkX / OSMnx baselines and includes staged timings for graph construction versus per-query work:
python benchmarks/comparison.py
Current benchmarks are intentionally kept in benchmarks/ rather than treated
as a universal claim. Performance depends on graph size, network profile,
machine, cache state, and output geometry settings.
License
Graphways is open source and licensed under the MIT license. OpenStreetMap data is licensed separately; when using OSM-derived outputs, follow the OpenStreetMap attribution guidelines.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file graphways-0.4.0-cp310-none-win_amd64.whl.
File metadata
- Download URL: graphways-0.4.0-cp310-none-win_amd64.whl
- Upload date:
- Size: 1.7 MB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0015ce38438c2e36dbf4c3273fb6744482ffa33be9f8919905f4c469fb0f9eec
|
|
| MD5 |
0f45e63970c3c7662495ae00ce2c0eb5
|
|
| BLAKE2b-256 |
f22361183664e1492c73af6001950712df0e618c622964ea975109ab6426c8bf
|