flownet provides efficient tools for transportation modeling in R, supporting network processing, route enumeration, and traffic assignment tasks. It implements the path-sized logit (PSL) model for traffic assignment and provides powerful utilities for network processing/preparation.
Network Processing
linestrings_to_graph() — Convert LINESTRING geometries to graphcreate_undirected_graph() — Convert directed graph to undirectedconsolidate_graph() — Consolidate graph by removing intermediate nodessimplify_network() — Simplify network graph
Traffic Assignment
run_assignment() — Run traffic assignment using path-sized logit model
Graph Utilities
normalize_graph() — Normalize node IDs to consecutive integersnodes_from_graph() — Extract unique nodes from graphlinestrings_from_graph() — Convert graph to LINESTRING geometriesdistances_from_graph() — Compute distance matrix from graph
OD Matrix Utilities
melt_od_matrix() — Convert origin-destination matrix to long format
Data
africa_trade — Average BACI HS96 2012-22 trade flows by section between 47 continental African countriesafrica_cities_ports — The 453 largest (port-)cities in continental Africa within a 70km radius - from Krantz (2024), doi:10.1596/1813-9450-10893
africa_network — African continental road network + extensions to optimally connect the 453 cities - from Krantz (2024), doi:10.1596/1813-9450-10893
africa_segments — Primary segments derived from OpenStreetMap routes between the 453 cities - from Krantz (2024), doi:10.1596/1813-9450-10893
Replication materials: https://github.com/SebKrantz/OptimalAfricanRoads
Details
The package uses efficient C implementations for critical path operations and leverages:
collapse- Fast data transformationsgeodist- Fast geodesic distance computationsigraph- Graph operations and shortest path algorithmsleaderCluster- Fast spatial clustering for network simplification
References
Ben-Akiva, M., & Bierlaire, M. (1999). Discrete choice methods and their applications to short term travel decisions. In R. W. Hall (Ed.), Handbook of Transportation Science (pp. 5-33). Springer US. doi:10.1007/978-1-4615-5203-1_2
Cascetta, E. (2001). Transportation systems engineering: Theory and methods. Springer.
Ben-Akiva, M., & Lerman, S. R. (1985). Discrete choice analysis: Theory and application to travel demand. The MIT Press.
Ramming, M. S. (2002). Network knowledge and route choice (Doctoral dissertation). Massachusetts Institute of Technology.
Prato, C. G. (2009). Route choice modeling: Past, present and future research directions. Journal of Choice Modelling, 2(1), 65-100. doi:10.1016/S1755-5345(13)70005-8
AequilibiaE Python Documentation: https://www.aequilibrae.com/develop/python/route_choice/path_size_logit.html
Author
Sebastian Krantz sebastian.krantz@graduateinstitute.ch and Kamol Roy kamol.roy08@gmail.com
