Madina
Madina (Arabic for the word ‘city’) is a package of classes and functions to streamline the representation and analysis of urban networks. The package includes a python implemetation of the Urban Network Analysis tools (Homepage). The source code for Madina is available on github.
Referencing in Your Research
To reference this package in your research, you can cite the paper available on SSRN:
Sevtsuk, A., & Alhassan, A. (2025). Madina Python Package: Scalable Urban Network Analysis for Modeling Pedestrian and Bicycle Trips in Cities. Journal of Transportation Geography, Online (Feb 2025). https://doi.org/10.1016/j.jtrangeo.2025.104130
@article{Sevtsuk2025, author = {Andres Sevtsuk and Abdulaziz Alhassan}, journal = {Journal of Transportation Geography}, title = {Madina Python Package: Scalable Urban Network Analysis for Modeling Pedestrian and Bicycle Trips in Cities}, volume = {Online (Feb 2025)}, url = {https://doi.org/10.1016/j.jtrangeo.2025.104130}, year = {2025},
}
Examples and Notebooks
The example notebooks and the datat needed to run them are available in the github repository, or could be downloaded from this link
Notebooks:
- 1) Loading Data and Creating Maps in Madina
- 2) Creating a Network, Diagnosis, understanding network structure
- 3) Urban Network Analysis (UNA) Tools: Accessibility, Closest Facility and Service Area
una.accessibility()- Reach Indexuna.service_area(): Finding catchment areas- Modifying attributes in layers
una.accessibility()- Gravity Index- Comparing Reach and Gravity of People to Subway
una.accessibility(): Closets Facilities and Distances- The Reverse: Reach and Gravity of Subway to People
- KNN Access to trains: acccessibility to suffecient destinations.
- Saving output into files
- 4) Urban Network Analysis (UNA) Tools: Alternative Paths and Betweenness
- una.alternative_paths
- una.alternative_paths - Turn Penalty
- una.betweenness
- Classical Betweenness Centrality
- Impact of Detour:
- Impact of Decay:
- Impact of Percieved Distance:
- Impact of Many Destinations
- Impact of Destination Weights:
- Impact of Elastic Trip Generation:
- Impact of Many Origins
- Impact of Parallell Processing
- Notes on performance.
- 5) Pedestrian Flow over Multiple Pairs of Origins and Destinations.
- 6) UNA Workflows
UNA Access Metrics Workflow
The package provides a streamlined way to measure multiple access metrics from one origin to multiple destinations
Prepare input data files (Network, origin and destination layers) inside a folder
Cities/city_name/DataPrepare and fill a pairing table and save it in the input folder
Run this code snippet:
from madina.una.workflows import betweenness_flow_simulation KNN_accessibility( city_name='Somerville', pairings_file="pairing.csv", num_cores=8, )
Instructions for Preparing and Running Accessibility workflows:
UNA Pedestrain Flow Simulation
The package enables modelling pedestrian accessibility and movement in urban areas between pairs of pre-specified origins and destinations. This can be done by following these steps:
* Prepare input data files for the network, and each origin and destination. Place all data in a folder called Cities/city_name/Data
Fill in the pairing table to specify origin-destination pairs, and specify specific parameters for each pair. Save the filled pairing table in the same
Cities/city_name/Datafolderrun the simulation:
from madina.una.betweenness import betweenness_flow_simulation betweenness_flow_simulation( city_name="new_york" )
Output would be saved in
Cities/city_name/Simulations.More instructions on running a pedestrain flow simulation, preparing data and creating the pairing table are found in the documentation here
Instructions for Preparing and Running a Simulation:
Documentation: Package Modules, Classes and Functions