The repository contains the source code to model traffic speed based on OpenStreetMap and Twitter data using Uber data as reference. It was used to generate the results for the paper:
C. Ludwig, J. Psotta, A. Buch, N. Kolaxidis, S. Fendrich, M. Zia, J. Fürle, A. Rousell, A. Zipf (2023): Traffic speed modelling to improve travel speed estimation in openrouteservice. FOSS4G 2023, Prizren, 26 June - 2 July 2023.
- Python >= 3.10
- poetry >=1.3.2
- docker
- gunzip
After you have cloned the repository, use poetry to set up a virtual environment with all required dependencies.
cd foss4g-2023-traffic-speed-model
poetry install
To activate the environment execute poetry shell
or run all python commands with poetry run python ...
.
A postgis database is required to store the processed data. You can set up a database using docker:
cd foss4g-2023-traffic-speed-model
docker compose up -d
-
Download the preprocessed input data from Zenodo and store it in the directory
./db-backup
. -
Load the preprocessed data into the database (this may take a while)
cd foss4g-2023-traffic-speed-model/db-backup
gunzip < preprocessed_2023-04-25_12_29_03.gz | docker exec -i db-traffic-speed-model psql -U postgres -d postgres`
docker exec -t db-traffic-speed-model pg_dumpall -c -U postgres | gzip > ./preprocessed_$(date +"%Y-%m-%d_%H_%M_%S").gz
To reproduce the results of the paper this step is not necessary if you have loaded the preprocessed data into the database. This step only needs to be performed if you are using new data which is not yet in the database.
Adjust the file paths in the config file ./config/config_aois_allcities. The model parameters are defined in ./config/modelling. These do not have to be adjusted to reproduce the results.
Example: Run model training for Nairobi with target variabel 85th percentile traffic speed
python ./modelling.py -a nairobi -c ../config/config_aois_allcities.json -m ../config/modelling/model_features_speed_kph_p85.json
If you want to run model training for several config files at once, you can use the batch file in ./traffic_speed_model/batch.
./batch_modelling.sh nairobi
To predict traffic speed for certain models run. Prediction will only be performed if the value predict = True
in the modelling config file.
python ./prediction.py -a nairobi -c ../config/config_aois_allcities.json -m ../config/modelling/model_features_speed_kph_p85.json
If you want to run the prediction for several config files at once, you can use the batch file in ./traffic_speed_model/batch.
./batch_prediction.sh nairobi
To export the predicted traffic speed data run:
python ./export.py -a nairobi -t speed_kph_p85 -c ../config/config_aois_allcities.json
If you want to run the export for several config files at once, you can use the batch file in ./traffic_speed_model/batch.
./batch_prediction.sh nairobi
This project is licensed under the MIT License - see the LICENSE file for details
- Christina Ludwig
- Anna Buch
This project was funded by the German Federal Ministry for Digital and Transport (BMDV) in the context of the research initiative mFUND.
Project term: 02/2021 - 01/2022
Data for model training retrieved from Uber Movement, (c) 2022 Uber Technologies, Inc., https://movement.uber.com.
Twitter data retrieved from Twitter Developer Platform
OpenStreetMap data retrieved using ohsome API. (c) OpenStreetMap contributers.