Skip to main content

transitio

AOI-driven OSM and GTFS acquisition, validation and repair — companion to pyrosm and cafein. transitio moves the raw ingredients of routing — OSM extracts and GTFS timetables — from the open data ecosystem to your area of interest, validated and repaired, ready for cafein to brew into routing results.

Status: early development. Acquisition (Mobility Database catalog, the feed index + OSM extracts), GTFS validation, repair and cropping are in place, tied together by the one-call transitio.fetch pipeline.

The feed index that transitio.index reads is built in a separate repository, transitio-dev/transitio-index.

Quick example

import transitio

# One call: OSM extract + validated GTFS feeds for an area of interest.
result = transitio.fetch(helsinki_polygon)        # any shapely geometry,
                                                   # bbox tuple or place name
result.osm_pbf     # cropped OSM extract (path)
result.feeds       # downloaded, cropped and validated GTFS feeds (paths)
result.reports     # per-feed merged validation reports
result.skipped     # (feed id, reason) for anything left out

net = result.to_cafein()   # routable cafein.TransportNetwork
osm = result.to_pyrosm()   # pyrosm.OSM reader over the extract

fetch shows its progress on stderr, a bar per download (a widget in Jupyter with pip install "transitio[notebook]", which adds ipywidgets); progress=False turns it off.

fetch accepts when="2026-09-01" to pick the dataset versions covering a service day (needs a free Mobility Database API token, passed as refresh_token= or via the MOBILITY_API_REFRESH_TOKEN environment variable), modes=["rail", "tram"] to keep only feeds serving given modes, repair=True to repair feeds after the crop, osm=False to skip the OSM extract when only the timetables are needed, and crop=False to keep feeds whole. With a token, GTFS downloads are catalogued dataset versions verified against catalog checksums; without one, the latest hosted zips are fetched as-is — unverified moving targets.

With the feed index installed (below), fetch takes the feeds of the index places that cover the area, when they cover at least half of its land, and result.places lists those places. Otherwise it searches the Mobility Database catalogue for feeds whose bounding box meets the area's, and a warning gives the reason and the number of feeds before anything is downloaded; index=False searches the catalogue without the index or a warning.

Feeds for a place

The feed index lists the feeds serving each place, by the tier of service they run there: local, regional, national or international. Install it once, then fetch a place's feeds by tier:

import transitio

transitio.index.refresh()            # once: install the newest feed index

augsburg = transitio.place("Augsburg")
result = transitio.fetch(
    place=augsburg,
    tiers=["local", "regional"],     # leave out long-distance services
    osm=False,                       # timetables only
)
transitio.merge_feeds(result.feeds, "augsburg.gtfs.zip", check=False)

The first refresh downloads about 420 MB (about 35 s at 100 Mbit/s, 3 minutes at 20 Mbit/s) and takes about 10 s more to unpack and check it; it prints its progress to stderr unless called with progress=False. A snapshot takes about 550 MB on disk, and the cache keeps the newest three plus a pinned one, up to about 2.2 GB; a refresh needs about 1 GB free while it runs.

Each feed is cropped to the place's boundary; a national feed such as Germany's is streamed through the crop, so it fits in memory bounded by the area. merge_feeds writes one feed from the cropped ones; with check=False it keeps the file when the validator reports errors, which the returned report lists. A bare name resolves to the city before the metros named after it. Where different places share a name and none clearly leads, as for London in the UK and in Canada, place raises AmbiguousPlaceError; a qualifier names the region or country that holds the place, as in "London, Ontario" or "City of London, UK", kind="city" (or "metro", "region", "country") restricts the scope, and a Wikidata id picks one place. A metro delineated under several definitions resolves to one of them, by the order functional urban area, metropolitan statistical area, metropolitan region, FAO city-region, though a city's own metros (those in its country) keep every definition; definition= names one instead. A partial name raises PlaceNotFoundError, which lists the places it partly matches; transitio.suggest completes names.

Inferring missing route shapes

Many feeds ship without shapes.txt, leaving every consumer to draw straight lines between stops. infer_shapes fills that gap from an OSM extract — matching OSM route relations where they exist, map matching over tram, rail and bus-drivable networks where they do not — and writes a feed carrying real alignments:

report = transitio.infer_shapes(
    "feed.zip", "shaped.zip", pbf, strictness="strict"
)
report["written"]     # shapes written
report["shapes"]      # per shape: method, matched OSM relation, score
report["skipped"]     # per refused pattern: the stage that refused it

How much inference is acceptable is yours to choose. "strict" (the default) writes only unambiguous matches; "relaxed" and "permissive" trade certainty for coverage, which is the trade worth making where a feed has no shapes at all and the alternative is a straight line. Every shape is validated against the pattern's own stops before it is written — each stop must lie on the alignment, in order — so no level writes a shape the feed's own data contradicts.

On the Helsinki tram fixture with the feed's shapes withheld, the levels measured (scripts/validate_shapes.py):

level shapes written median length error worst offset
strict 35/80 0.9% 42 m
relaxed 40/80 0.9% 34 m
permissive 43/80 0.9% 184 m

Helsinki's OSM data is unusually good; expect a worse trade where it is not, and keep the report.

Lower-level access

Each pipeline stage is available on its own:

db = transitio.MobilityDatabase()

feeds = db.search_feeds(aoi=helsinki_polygon)
dataset = db.dataset_for(feeds[0], when="2026-09-01")
path = db.download(dataset)                        # cached, checksum-verified
report = db.validation_report(dataset)             # hosted canonical-validator report

pbf = transitio.fetch_pbf(helsinki_polygon)       # cropped OSM extract
validation = transitio.validate_feed(path)        # canonical-code notices
transitio.repair_feed(path, "repaired.zip")       # gtfstidy-contract repair
transitio.crop_feed(path, "cropped.zip", aoi=helsinki_polygon)

Documentation

The Sphinx site lives in docs/. Building it needs transitio itself installed (autodoc imports the real package) plus the Sphinx toolchain:

pip install . -r docs/requirements.txt
sphinx-build -b html docs docs/_build/html

The hosted version lives at https://transitio.readthedocs.io.

Installation

pip install transitio

Binary wheels cover Linux, macOS and Windows. Building from source instead requires a Rust toolchain (pip install .). pip install "transitio[notebook]" also installs ipywidgets, so the download progress bars show as widgets in Jupyter.

License

MIT

Metadata

Release files for transitio 0.21.3

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

Source distribution (sdist)

Source distribution for transitio 0.21.3
File Size Uploaded
transitio-0.21.3.tar.gz 388.5 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for transitio 0.21.3
File
transitio-0.21.3-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details
transitio-0.21.3-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details
transitio-0.21.3-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.10 abi3 Linux glibc 2.17+ ARM64 Details
transitio-0.21.3-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details
transitio-0.21.3-cp310-abi3-macosx_10_12_x86_64.whl CPython 3.10 abi3 macOS 10.12+ x86-64 Details

Total release size: 9.0 MB

Release files / transitio-0.21.3.tar.gz

Download URL transitio-0.21.3.tar.gz
Size 388.5 kB
Tags Source
SHA-256 checksum
How to use checksums
df921b1f722b742bd22dc46e85bbacc7a2fa4620c8ebe40e7117c218fee74ac0
BLAKE2b-256 checksum
How to use checksums
6ae14f2c31c8cf8d6e2ea7e1ede171f069b8cf4f2cecec23a4c3a7edab972299
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 9, 2026.

Transparency log

Release files / transitio-0.21.3-cp310-abi3-win_amd64.whl

Download URL transitio-0.21.3-cp310-abi3-win_amd64.whl
Size 1.6 MB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
ecae296f69d3cf379b3e21f9cec53542e6bd8857f1813f47f7aab4847426427c
BLAKE2b-256 checksum
How to use checksums
33aa720687599836ec505fd9d9556a1b6aa4083c4e38340abf3bf6b2d36b82db
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 9, 2026.

Transparency log

Release files / transitio-0.21.3-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL transitio-0.21.3-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 1.8 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
9dd9d094d6ade062dfa655ac0bc22b64404a02a0ec35d28dd1737c0c089cc964
BLAKE2b-256 checksum
How to use checksums
5f44bb205145526e2481057b2a6de5ccaa159897b0586a8d3f1de837bf65f5fb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 9, 2026.

Transparency log

Release files / transitio-0.21.3-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL transitio-0.21.3-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 1.8 MB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
60374c0c442c68a07d75b3571fdf0c87d1fbf74fa6e77f328f6c8c83a1d19512
BLAKE2b-256 checksum
How to use checksums
dafa3595669890cba859855a8cf2acf4dfa432de9d2c287caaa8a1ce14beb9ab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 9, 2026.

Transparency log

Release files / transitio-0.21.3-cp310-abi3-macosx_11_0_arm64.whl

Download URL transitio-0.21.3-cp310-abi3-macosx_11_0_arm64.whl
Size 1.6 MB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
d8444277ce5a030b259f471bc2d6db4a20f878aa20ebbfcce94ba0210c72941b
BLAKE2b-256 checksum
How to use checksums
880d508d664eadbeb474d5712c96fd97ca909df598e302f4d182d7a459c64e0c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 9, 2026.

Transparency log

Release files / transitio-0.21.3-cp310-abi3-macosx_10_12_x86_64.whl

Download URL transitio-0.21.3-cp310-abi3-macosx_10_12_x86_64.whl
Size 1.8 MB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
3b835a759d877595fea8bc9c2fbbd7f4ccfa5255778dfa07d4f352b108d46341
BLAKE2b-256 checksum
How to use checksums
0c5a98540b94ab325bd93280dfbf6549fee4911f539095dbde71fd294022d2b1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 9, 2026.

Transparency log
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