Generate transit maps from OSM data in docker
![Product Name Screen Shot][product-screenshot]
There are many great public transport routing services online, however, I stil need static maps of public transit lines. I want to create a automatic process for generate static maps from OpenStreetMap data, with simply running routine.
Here's why:
A data features, needed to orientation by static public transport map is
This scripts provive points 1, 2, 3, calculating from OSM data. And also 5 and 6.
This section should list any major frameworks that you built your project using. Leave any add-ons/plugins for the acknowledgements section. Here are a few examples.
This script run in Docker container, witch can be run on any modern OS.
Install git. Here is git submodules, download zip from github will not work. See https://github.com/git-guides/install-git
git clone --recurse-submodules https://github.com/trolleway/OSMTram.git
cd OSMTram
docker build -t osmtram:1.0 .
#start postgis container
docker run --rm --name osmtram_backend_db -e POSTGRES_PASSWORD=user -e POSTGRES_USER=user -e POSTGRES_DB=gis -d -p 5432:5432 mdillon/postgis
#start and go to container with ubuntu+python+gdal, with network link to postgis
docker run --rm -it --link osmtram_backend_db:db -v ${PWD}/data:/data osmtram:1.0 /bin/bash
# on Windows run in powershell
time python3 run.py russia.json --workdir /data --basemap-caching --where "name_int='Volgograd' and route='tram'"
Same as prod, but mount code folder to container, no need to rebuild container at code change
git clone --recurse-submodules https://github.com/trolleway/OSMTram.git
cd OSMTram
docker build -f Dockerfiledev -t osmtram:dev .
#run postgis in docker
docker run --rm --name osmtram_backend_db -e POSTGRES_PASSWORD=user -e POSTGRES_USER=user -e POSTGRES_DB=gis -d -p 5432:5432 mdillon/postgis
#win
docker run --rm -it --link osmtram_backend_db:db -v ${PWD}/data:/data -v ${PWD}:/OSMTram osmtram:dev /bin/bash
time python3 run.py italy-sud.metadata.json --workdir /data
time python3 run.py poland.json --skip-osmupdate --workdir /data --where "name_int = 'Gdansk'"
time python3 run.py russia.json --skip-osmupdate --basemap-caching --workdir /data --where "name_int = 'Ekaterinburg' and route='tram'"
time python3 run.py russia.json --basemap-caching --workdir /data --where "name_int = 'Ekaterinburg' and route='trolleybus'"
time python3 run.py russia.json --skip-osmupdate --workdir /data --where "not valid"
At next run a map will rendered using changed project.
graph TD
A[run.py] -->|countryname.json| B(Read boundaries geojson)
B --> |wget/osmupdate| C(download and upgrade OSM dump)
C -->|osmconvert/osmium| D[Crop OSM by BBOX]
D -->|ogr| E[Convert OSM to GPKG with basemap]
C -->|core/process_routes.py osmfilter| ROUTES[extract route relations to pbf]
ROUTES -->|core/process_routes.py osm2pgsql| POSTGIS[import routes pbf to PostGIS]
POSTGIS -->|core/osmot python| POSTGIS2[Generate route labels for streets]
POSTGIS2 -->|core/osmot python| POSTGIS3[Generate arrows labels for one-way routes]
POSTGIS3 -->|core/osmot python| POSTGIS4[Generate terminal points]
POSTGIS4 -->|core/osmot ogr2ogr| ROUTES.GEOJSON[Export lines, terminals to GeoJSON]
ROUTES.GEOJSON -->|qgis| QGIS[render map from files in QGIS to svg, png, pdf]
E -->| |QGIS
This is a docker container. It uses for input a bbox, filter string and map style, and generate a png image file.
It consists from there scripts:
core/dump_prepare.py - Takes a url or pbf file, poly file, filter string, and filtering it to basemap.pbf and pt_data.pbf. Use osmfilter.
core/historical_dump.py - Download and prepare historical dump for dump_prepare. May will be run outside container, due to huge size of dumps. Use osmupdate and osmfilter.
core/basemap_process.py - Generate image of basemap for bbox. Importing basemap.pbf to postgis, create QGIS Server WMS, make png from WMS.
core/pt_data_process.py - Generate image of public transport map
core/pyqgis_client_atlas.py - render pdf/svg/png map using standart qgis project with atlas layout. Extent is set in geojson file. One run generate one-page atlas, then pages combined in multi-page pdf or zip archive
Script start QGIS in docker container, make copy of QGIS project from /qgis_project_templates, put data layers into gpkg files, and run QGIS operation "Atlas rendering"
Distributed under the MIT License. See LICENSE
for more information.