Python toolkit for cross-modal accessibility analysis on transport networks.
Project description
aperta
A Python toolkit for cross-modal accessibility analysis on transport networks — routing, distance/time computation, utility-based travel costs, and gravity- and logsum-based accessibility metrics on networkx graphs (routed via scipy.sparse.csgraph).
The name is Latin/Italian for open — the condition that accessibility, at root, measures.
Status
Pre-1.0, alpha. Published alongside a toolkit paper (in submission). APIs may change without notice until v1.0.
Install
pip install aperta # algorithms only
pip install 'aperta[osm]' # + OSM ingestion (osmnx)
pip install 'aperta[examples]' # + everything needed to run the example notebooks
Requires Python ≥ 3.11.
The osm_helpers and topography modules import their backing libraries
(osmnx, rasterio, requests) lazily — install the matching [osm] /
[topo] extra if you use them, otherwise an ImportError surfaces at first use.
For development:
git clone git@github.com:mmiotti/aperta.git
cd aperta
pip install -e ".[osm,topo,h3]"
python -m unittest discover -s tests -t .
If you plan to edit the example notebooks under
examples/, run the jupytext + nbstripout setup once after cloning. Not needed if you're only using the library or modifying Python source.
Workflow
Aperta is organized around a six-phase workflow. Phases 4 and 5's calibration sub-step are optional; the rest is the minimum end-to-end pipeline.
- Load and prepare data — networks (one per mode), land use, topography, optional ground-truth data (traffic counters, travel-survey times).
- Map data to units — aggregate source data into the
cells → zoneshierarchy; snap geo units to network nodes. - Build sparse OD pairs — the tiered OD structure (three distance tiers) with per-cell origins at near range and zone-aggregated destinations at far range, keeping per-origin compute bounded independently of network extent.
- (Optional) Estimate traffic flows — sampled betweenness centrality; optionally calibrate against observed counter data.
- Estimate travel costs — shortest paths on the routing graph plus per-cell trip overheads. Optionally: utility-based generalized costs and edge-weight calibration against observed travel times.
- Calculate accessibilities — cumulative-opportunity, gravity, nearest-k, logsum (and cross-modal aggregation across per-mode results).
See the API reference for which module covers each phase and for the specific functions.
Runnable examples, in increasing depth:
- examples/minimal/accessibility.ipynb — what aperta does in ~50 lines using only OpenStreetMap. Cambridge MA, ~10 s.
- examples/walkthrough/accessibility.ipynb — guided tour of every primitive; walking + cycling, cross-modal logsum, path-first per-edge feature aggregation. Central Paris, ~1 min end-to-end.
- examples/extended/ — production-scale Bern + 40 km: prep pipeline, calibration against observed travel times, traffic-flow estimation, accessibility analysis. ~30 min.
The toy-world end-to-end test in tests/test_workflow.py doubles as the smallest possible walk-through (~150 lines, runs in a second).
Quick example
The three-line core of an accessibility analysis: build the tiered OD pairs, route shortest paths, count opportunities within a travel-time budget.
from aperta import accessibility, od_pairs, routing
pairs = od_pairs.get_pairs(cells, r_cells=2000.0, node_column='node_id')
times = routing.tiered_path_costs(pairs, graph, weight='walk_time_s')
acc = accessibility.cumulative_opportunities(
times, {'supermarkets': weights}, {},
[accessibility.Bin('15min', 0, 15 * 60)],
)
A complete, runnable version (OSM ingestion, plotting): examples/minimal/accessibility.ipynb.
Modules
See the API reference for module-by-module documentation.
Design
What aperta is:
- Path-first. Routing returns the realized route alongside the cost as a single primitive, so per-edge attributes (gradient, exposure, surface, perceived safety) aggregate along the path natively — the architectural prerequisite for utility-based and route-aware accessibility.
- Cross-modal. Mode and network are orthogonal: one network per mode, with
min/logsumaggregation across modes as a first-class operation. Generalizes to any axis of network variation — time-of-day, congestion regime, infrastructure scenario. - Multi-scale. A tiered cell / zone OD structure bounds per-origin computation independently of network extent — country-scale reach without country-scale destination counts.
- Live-graph routing. Dijkstra on the graph directly, no precomputed index. Slower per query than contraction-hierarchy tools, but edge-weight changes are immediate — what makes iterative calibration and scenario comparison practical.
What aperta is not:
- No filesystem assumptions. Algorithm functions take plain
networkxgraphs,pandas/geopandasframes, andnumpyarrays — no file I/O. - No DAG engine, no global state. No caching, no dependency tracking, no orchestration. Every function takes its inputs explicitly. For DAG features, layer DVC or Snakemake on top.
Interoperability with other accessibility tools
Aperta deliberately doesn't try to do everything in-house. Two interoperability patterns are worth flagging:
- Public transit via R5. Aperta has no native public-transit support right now (no GTFS reader, no RAPTOR-style time-dependent routing). Anything that can be expressed as a
networkxgraph with appropriate edge weights — including simplified transit-as-graph models — will route in aperta like any other network. For full GTFS-based transit routing (calendars, transfers, frequency-based services), the pragmatic pattern is to compute the transit OD cost matrix with R5 (via r5py), align its origins/destinations to the same cell layer aperta uses, and feed the resulting per-mode cost ODM intood_pairs.aggregate_across_modesalongside the walk / cycle / car ODMs computed by aperta. The cross-modal aggregation proceeds identically whether each per-mode ODM came from aperta's router or elsewhere. - Faster cost-only routing via Pandana/pandarm. Aperta's live-graph routing is the right trade-off for path-first, iterative, and scenario-comparative workloads, but for one-shot cost-only accessibility on a large fixed network, contraction-hierarchy backends like Pandana (and its recent modernized fork pandarm) route faster per query. The calibrated edge weights produced by
calibration.calibrate_edge_weightsare plain per-edge attributes on thenetworkxgraph and transfer cleanly to a Pandana/pandarm network built from the same OSM extract — i.e., you can calibrate edge weights in aperta and then route with them in Pandana/pandarm.
Benchmark vs Pandana
Ultimate speed for the full accessibility stack was not aperta's goal. Nonetheless, aperta typically runs within 1–5× of Pandana on equivalent cumulative-opportunity workloads. When the area of interest (for which to calculate accessibilities) is substantially smaller than the buffer zone (destinations to consider), or when aiming to recalculate accessibilities for a select subset of locations after a graph topology or edge weight change, aperta can even be faster than Pandana. See the benchmark for the full setup and numbers, or run examples/extended/benchmark.py to reproduce.
Acknowledgments
Aperta was developed at the Chair of Ecological Systems Design at ETH Zurich in the context of the BlueCity project and LUMOS.
Cite this
If you use aperta in a publication, please cite the archived release:
@software{miotti_aperta_2026,
author = {Miotti, Marco},
title = {{Aperta: Path-first, cross-modal accessibility analysis in Python}},
year = 2026,
publisher = {Zenodo},
doi = {10.5281/zenodo.XXXXXXX},
url = {https://doi.org/10.5281/zenodo.XXXXXXX}
}
License
MIT. See LICENSE.
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 Distribution
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 aperta-0.1.0a0.tar.gz.
File metadata
- Download URL: aperta-0.1.0a0.tar.gz
- Upload date:
- Size: 165.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
def4932d175c6e34084ebf4d9df8478df59186cf9c9f5d23104abb48fa2d009f
|
|
| MD5 |
59a5df3d635162c37782fe1ebb095074
|
|
| BLAKE2b-256 |
c59bb217ea3f482a0d3a4dd90c3b2f35ff8d1417172f1ac8619019872419e76b
|
File details
Details for the file aperta-0.1.0a0-py3-none-any.whl.
File metadata
- Download URL: aperta-0.1.0a0-py3-none-any.whl
- Upload date:
- Size: 115.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7c1767b431a5d670d475472d1014f2650cd99001ebde5a55bbfd3ac956943ac8
|
|
| MD5 |
909fe0280911b070dab74070737f0dc2
|
|
| BLAKE2b-256 |
2fb2a81b64639aa85d4280ed9a335e163426b3337fb757f530b5ea1012865123
|