The code is based on a combination of Python and SQL scripts.
To run the code, first install the required dependencies:
First clone this repository (recommended) to your local machine or download it.
To avoid cloning the history and larger branches with example data and plots, use:
git clone -b main --single-branch [url to GitHub repository] --depth 1
Install Postgresql version 14.10 or newer.
See this link for a guide to installing Postgresql with homebrew on Mac.
PgAdmin is not required, but can be useful when inspecting the results: Guide for installing PgAdmin.
Install the Postgresql extensions PostGIS and PgRouting.
If using homebrew, once Postgresql is installed, run:
brew install postgis
brew install pqrouting
osm2pgsql is used to load OSM to Postgresql with all desired OSM tags.
On Mac, osm2pgsql can be installed by running:
brew install osm2pgsql
osm2po is used for loading OSM data to Postgresql in a format compatible with PgRouting.
The necessary files are already included in this repository. If a newer version is needed, replace the content in the folder osm2po. (See e.g. this link for an installation guide.)
If a newer version is used, once installed, replace the osm2po.config file with the one included on this repository.
Used for loading the GeoDanmark geopackage to PostgreSQL.
On mac, run:
brew install gdal
To ensure that all packages needed for the analysis are installed, it is recommended to create and activate a new conda environment using the environment.yml
:
conda env create --file=environment.yml
conda activate dk_bike_network
If this fails, the environment can be created by running:
conda config --prepend channels conda-forge
conda create -n dk_bike_network --strict-channel-priority geopandas psycopg2 sqlalchemy geoalchemy2 pyarrow pyyaml ipykernel
The repository has been set up using the structure described in the Good Research Developer. Once the repository has been downloaded, activate the dk_bike_network environment, navigate to the main folder in a terminal window and run the commands:
conda activate dk_bike_network
conda install pip
pip install -e .
The workflow makes use of 4 different data sets:
-
OpenStreetMap Download the newest OSM-pbf file for Denmark (
denmark-latest.osm.pbf
) from, for example, GeoFabrik and place it in the folderdata/raw/road_networks/
. -
GeoDanmark Download the data set of the Danish road network ('Vejmidte') from Dataforsyningen and place it as
vejmidte.gpkg
indata/raw/road_networks/
. -
Municipal boundaries Download the data set with municipal boundaries from Dataforsyningen and place it in the folder
data/raw/study_area/muni_boundary.gpkg
. -
Land use Download the data set of urban and summerhouse zones from e.g. Miljøportalen and place it in the folder
data/raw/urban/
with the file namezonekort_samlet_v.gpkg
.