This notebook aims to calculate travel distances between different regions. Since the regions are more extensive, we can't just take the center of the area as a starting/ending point: It is essential to know where people are traveling from. Simplification: We assume that everyone in one region visits another equally often. That means we neglect the effect that border regions visit neighboring regions more frequently than other parts of an origin region. Furthermore, we always route via a particular road near Monte Ceneri since other data (Swisscom) is measured there.
Step by step:
- Import regions and population density
- Divide regions into squares with side lengths of 300m
- Assign squares to regions
- Calculate the population in squares: Absolute population and relative population per region
- select dense squares: Select only the most populated squares per region. Select squares to include 90% of the population.
- Calculate distance region A --> region B :
- Calculate all distances from dense squares in A to dense squares in B
- Average distances weighted by the product: relative_population_in_square_A * relative_population_in_square_B.
- export as csv
- container virtualization Docker to run Valhalla
- development environment Java Development Kit to run OpenTripPlanner
- programming language Python 3.11 to run the main script as an Jupyter notebook
- Install python packages with
pip: -r requirements.txt
docker run -dt --name valhalla_gis-ops -p 8002:8002 -v $PWD/custom_files:/custom_files -e tile_urls=https://download.geofabrik.de/europe/switzerland-latest.osm.pbf gisops/valhalla:latest
for the 2019 schedule:
cd src/OpenTripPlanner
java -jar otp-1.5.0-shaded.jar --build graphs/ch2019_tiny_TI/ --inMemory --port 2019 --securePort 8019
for the 2022 schedule:
cd src/OpenTripPlanner
java -jar otp-1.5.0-shaded.jar --build graphs/ch2022_tiny_TI/ --inMemory --port 2022 --securePort 8022
Output details:
- population density is aggregated into a 300m square grid
- 80% of the whole population is represented by a selection of 3% of all squares which is 13% of the populated squares
- ÖV
- The routing is based on the GTFS data from 2019 and 2022
- The routing is multimodal for public transport (ÖV) combined with pedestrian
- It is routed directly between the regions without via Monte Ceneri
- The distance includes the complete route
- Time includes only travel time not walking time
- Car
- For verification purposes, the accessibility from Chiasso was calculated. The route was not explicitly routed via Monte Ceneri. The verification plots are in the folder
tests/
- For verification purposes, the accessibility from Chiasso was calculated. The route was not explicitly routed via Monte Ceneri. The verification plots are in the folder