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.
Preprint: arXiv:2107.02185
Data repository: [insert link]
Visualization: GrowBike.Net
Videos & Plots: http://growbike.net/download
The main folder/repo is bikenwgrowth
, containing Jupyter notebooks (code/
), preprocessed data (data/
), parameters (parameters/
), result plots (plots/
), HPC server scripts and jobs (scripts/
).
Other data files (network plots, videos, results, exports, logs) make up many GBs and are stored in the separate external folder bikenwgrowth_external
due to Github's space limitations.
conda create --override-channels -c conda-forge -n OSMNX python=3 osmnx=0.16.2 python-igraph watermark haversine rasterio tqdm geojson
conda activate OSMNX
conda install -c conda-forge ipywidgets
pip install opencv-python
conda install -c anaconda gdal
pip install --user ipykernel
python -m ipykernel install --user --name=OSMNX
Run Jupyter Notebook with kernel OSMNX (Kernel > Change Kernel > OSMNX)
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.
- Populate
parameters/cities.csv
, see below. - Run 01 and 02 once locally to download and prepare all networks and POIs (The alternative is server-side
sbatch scripts/download.job
, but OSMNX throws too many connection issues, so manual supervision is needed) - Upload
code/*.py
,parameters/*
,scripts/*
- Run:
./mastersbatch_analysis.sh
- Run, if needed:
./mastersbatch_export.sh
- After all is finished, run:
./cleanup.sh
Single (or few/small) cities could be run locally but require manual, step-by-step execution of Jupyter notebooks:
- Populate
parameters/cities.csv
, see below. - Run 01 and 02 once to download and prepare all networks and POIs
- Run 03,04,05 for each parameter set (see below), set in
parameters/parameters.py
- Run 06 or other steps as needed.
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"
- Go to e.g. https://nominatim.openstreetmap.org/search.php?q=paris%2C+france&polygon_geojson=1&viewbox= and enter the search string. If a correct polygon (or multipolygon) pops up it should be fine. If not leave the field empty and acquire a shape file, see below.
- Go to Overpass, to the city, and run:
relation["boundary"="administrative"]["name:en"="Copenhagen Municipality"]({{bbox}});(._;>;);out skel;
- Export: Download as GPX
- Use QGIS to create a polygon, with Vector > Join Multiple Lines, and Processing Toolbox > Polygonize (see Stackexchange answer 1 and Stackexchange answer 2)