Skip to content

Instantly share code, notes, and snippets.

@ThomasG77
Last active September 18, 2024 13:31
Show Gist options
  • Save ThomasG77/e5a9516780ca770ae806ac0ee2dff6f5 to your computer and use it in GitHub Desktop.
Save ThomasG77/e5a9516780ca770ae806ac0ee2dff6f5 to your computer and use it in GitHub Desktop.
Recette génération tuiles monde OpenMaptiles

Recette génération tuiles monde OpenMaptiles

# Machine de type c3-64 avec 64 Go RAM, VCore 32,	400 Go NVMe, réseau public 4 Gbit/s, réseau privé 4 Gbit/s max
# 1TB de disque dur
# Dsitribution Debian bookworm

# Install Docker
sudo su &&
apt update -y &&
apt install -y ca-certificates curl gnupg apt-transport-https gpg

# Download GPG key and store repository in the system
curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /usr/share/keyrings/docker.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker.gpg] https://download.docker.com/linux/debian bookworm stable" |tee /etc/apt/sources.list.d/docker.list > /dev/null 
apt update -y

# Install Docker packages
apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin docker-compose -y

# Prepare data
# Change path depending of HDD config and disk space
path_hdd=/media/geo-c3-64-gra11/
cd $path_hdd
mkdir data
# cd data
# wget https://planet.openstreetmap.org/pbf/planet-latest.osm.pbf
# cd ..

# See also https://github.com/onthegomap/planetiler/blob/main/PLANET.md#2-run-planetiler for configuration depending of available RAM.

# Run tiles generation
docker run -e JAVA_TOOL_OPTIONS="-Xmx40g" -v "$(pwd)/data":/data openmaptiles/planetiler-openmaptiles:latest --force --area=planet --bounds=planet --download-threads=10 --download-chunk-size-mb=1000 --download -Xmx40g --nodemap-type=sparsearray --storage=mmap --fetch-wikidata --output=/data/planet.mbtiles --building-merge-z13=false #--osm-path=/data/planet-latest.osm.pbf

# Update mbtiles metadata
sqlite3 planet.mbtiles \
"UPDATE metadata SET value = '<a href=\"https://www.etalab.gouv.fr/\" target=\"_blank\">&copy; Etalab</a> <a href=\"https://www.openmaptiles.org/\" target=\"_blank\">&copy; OpenMapTiles</a> <a href=\"https://www.openstreetmap.org/copyright\" target=\"_blank\">&copy; Contributeurs OpenStreetMap</a>' WHERE name = 'attribution';"

sqlite3 planet.mbtiles \
"UPDATE metadata SET value = '2.308097,48.850132,14' WHERE name = 'center';"

sqlite3 planet.mbtiles \
"UPDATE metadata SET value = 'Tuiles vectorielles d’usage général Monde' WHERE name = 'description';"

sqlite3 planet.mbtiles \
"UPDATE metadata SET value = 'Tuiles vectorielles Monde par Etalab' WHERE name = 'name';"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment