Open-Source Spatiotemporal Traffic Congestion Analysis at City Scale: A Reproducible Python Pipeline Combining PySAL, OSMnx, and Multilevel Modeling
Keywords: FOSS4G, reproducible pipeline, traffic analysis, PySAL, OSMnx, multilevel modelling
Abstract. City-scale spatiotemporal traffic analysis requires a long workflow—raw probe-data ingestion, segment matching to a stable reference network, temporal aggregation, exploratory spatial statistics, network-topology analysis, multilevel variance decomposition, and reproducible figure generation. Existing FOSS4G tools cover individual stages well (PySAL for spatial statistics, OSMnx for street networks, statsmodels for mixed models), but no integrated FOSS4G stack delivers all stages end-to-end with stable identifiers across provider data revisions. We present traffic-congestion-pipeline, an MIT-licensed Python package distributed on PyPI that closes this gap. The contribution comprises four engineering elements: (i) a provider-agnostic collector with HERE, TomTom, and Google back-ends behind a single interface; (ii) an OSM-based two-stage spatial matcher (geometric intersection followed by nearest-neighbour fallback) producing a stable osm_composite_id with 99.8% match rates across 50,000+ collection snapshots; (iii) a modular eleven-command CLI and Python API that allow each analysis stage to be run independently or chained into a single reproducible workflow; and (iv) demonstration on 316 million traffic observations from three Indonesian cities (Jakarta, Bandung, Semarang), processed end-to-end on consumer hardware in approximately fifteen minutes. The pipeline has supported a peer-reviewed empirical study and is, to our knowledge, the first FOSS4G stack to integrate provider-agnostic collection, OSM-stable segment identity, and multilevel variance decomposition into a single installable artifact.
