Skip to content

Files

Latest commit

May 22, 2024
c1e244e · May 22, 2024

History

History
105 lines (63 loc) · 4.29 KB

installation.md

File metadata and controls

105 lines (63 loc) · 4.29 KB

Installation

The code is based on a combination of Python and SQL scripts.

To run the code, first install the required dependencies:

1. Clone the GitHub repository

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

2. Install Postgresql

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.

3. Install PostGIS and PgRouting

Install the Postgresql extensions PostGIS and PgRouting.

If using homebrew, once Postgresql is installed, run:

brew install postgis

brew install pqrouting

4. Install osm2pgsql

osm2pgsql is used to load OSM to Postgresql with all desired OSM tags.

On Mac, osm2pgsql can be installed by running:

brew install osm2pgsql

5. Install osm2po

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.

6. Install GDAL

Used for loading the GeoDanmark geopackage to PostgreSQL.

On mac, run:

brew install gdal

7. Create conda environment

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

8. Install src package

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 .

9. Download data

The workflow makes use of 4 different data sets:

  1. OpenStreetMap Download the newest OSM-pbf file for Denmark (denmark-latest.osm.pbf) from, for example, GeoFabrik and place it in the folder data/raw/road_networks/.

  2. GeoDanmark Download the data set of the Danish road network ('Vejmidte') from Dataforsyningen and place it as vejmidte.gpkg in data/raw/road_networks/.

  3. Municipal boundaries Download the data set with municipal boundaries from Dataforsyningen and place it in the folder data/raw/study_area/muni_boundary.gpkg.

  4. 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 name zonekort_samlet_v.gpkg.