Last active
June 27, 2024 05:57
-
-
Save mikaelhg/2ec508b355398812fcb50d9da2d7603b to your computer and use it in GitHub Desktop.
Generate static, Helsinki only map tiles from OpenStreetMap data
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Bounding box from http://norbertrenner.de/osm/bbox.html | |
HELSINKI_BBOX=24.577,60.079,25.228,60.335 | |
# OpenStreetMap extract file from Geofabrik | |
wget https://download.geofabrik.de/europe/finland-latest.osm.pbf | |
# Cut the 500 MB Finland data file into a 34 MB Helsinki data file | |
# as this is much faster than using the import bbox. | |
osmconvert finland-latest.osm.pbf -b="$HELSINKI_BBOX" --out-pbf >helsinki.pbf | |
docker volume create openstreetmap-data | |
docker run --rm -it -e THREADS=8 \ | |
-v `pwd`/helsinki.pbf:/data.osm.pbf \ | |
-v openstreetmap-data:/var/lib/postgresql/12/main \ | |
overv/openstreetmap-tile-server import | |
# The result is a 1.7 GB PostgreSQL data directory. Consider putting the volume on /dev/shm instead. | |
docker volume create openstreetmap-data | |
docker run -it --rm --name=osm -p 80:80 -e THREADS=4 \ | |
-v openstreetmap-data:/var/lib/postgresql/12/main \ | |
-v openstreetmap-rendered-tiles:/var/lib/mod_tile \ | |
overv/openstreetmap-tile-server run | |
docker exec -it osm render_list -a -z 4 -Z 13 -n 4 -m ajt |
Generating tiles without PostGIS with t-rex
https://xycarto.com/2021/04/30/static-vector-tiles-ii-openlayers-with-custom-projection/
Converting to the GDAL GPKG (sqlite3) format:
ogr2ogr -f GPKG helsinki.gpkg helsinki.pbf
xz --threads=0 -fkv helsinki.gpkg
docker run -v `pwd`/helsinki.gpkg:/tmp/helsinki.gpkg:ro sourcepole/t-rex genconfig --datasource /tmp/helsinki.gpkg
docker run -p 6767:6767 -v `pwd`/helsinki.gpkg:/var/data/in/helsinki.gpkg:ro -v `pwd`/helsinki_gpkg.toml:/var/data/in/myconfig.toml:ro sourcepole/t-rex serve --bind=0.0.0.0 --openbrowser=false --config=myconfig.toml
A much better solution: https://gist.github.com/mikaelhg/edf65dfad43e240fb4c483587b5e7f93
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://openlayers.org/en/latest/examples/heatmap-earthquakes.html
https://github.com/Overv/openstreetmap-tile-server