This is the source code for the scientific paper Growing urban bicycle networks by M. Szell, S. Mimar, T. Perlman, G. Ghoshal, and R. Sinatra. The code downloads and pre-processes data from OpenStreetMap, prepares points of interest, runs simulations, measures and saves the results, creates videos and plots.
Paper: https://www.nature.com/articles/s41598-022-10783-y
Data repository: zenodo.5083049
Visualization: GrowBike.Net
Videos & Plots: https://growbike.net/download
Video output from running the code on Paris, showing the growth of a bicycle network on a grid of seed points
Run from your terminal:
git clone -b main --single-branch https://github.com/mszell/bikenwgrowth --depth 1
growbikenet
In your terminal, navigate to the project folder bikenwgrowth
and use conda
or mamba
or micromamba
to run:
mamba env create -f environment.yml
mamba activate growbikenet
If the above doesn't work, you can manually create the environment from your command line (not recommended):
mamba create --override-channels -c conda-forge -n growbikenet python=3.12 osmnx=1.9.4 python-igraph watermark haversine rasterio tqdm geojson
mamba activate growbikenet
mamba install -c conda-forge ipywidgets
pip install opencv-python
pip install --user ipykernel
If you want to use the environment growbikenet
in Jupyter, run:
python -m ipykernel install --user --name=growbikenet
This allows you to run Jupyter with the kernel growbikenet
(Kernel > Change Kernel > growbikenet)
Single (or few/small) cities can be run locally by a manual, step-by-step execution of Jupyter notebooks:
parameters/cities.csv
, see below. Leave default values to run the code on two small cities.code
folder.parameters/parameters.py
X_
can be run if needed to generate extra results or data.For multiple, esp. large, cities, running the code on a high performance computing cluster is strongly suggested as the tasks are easy to paralellize. The shell scripts are written for SLURM.
parameters/cities.csv
, see below.sbatch scripts/download.job
, but OSMNX throws too many connection issues, so manual supervision is needed)code/*.py
, parameters/*
, scripts/*
./mastersbatch_analysis.sh
./mastersbatch_export.sh
./cleanup.sh
./fixresults.sh
(to clean up results in case of amended data from repeated runs)The main folder/repo is bikenwgrowth
, containing Jupyter notebooks (code/
), preprocessed data (data/
), parameters (parameters/
), result plots (plots/
), HPC server scripts and jobs (scripts/
).
Most of the generated data output (network plots, videos, results, exports, logs) makes up many GBs and is stored in the separate external folder bikenwgrowth_external
. To set up different paths, edit code/path.py
prune_measure = "betweenness"
, poi_source = "railwaystation"
prune_measure = "betweenness"
, poi_source = "grid"
prune_measure = "closeness"
, poi_source = "railwaystation"
prune_measure = "closeness"
, poi_source = "grid"
prune_measure = "random"
, poi_source = "railwaystation"
prune_measure = "random"
, poi_source = "grid"
relation["boundary"="administrative"]["name:en"="Copenhagen Municipality"]({{bbox}});(._;>;);out skel;