SPB Git

Repository Public

build_dem.sh 3.9 KB 86 lines shellscript

1#!/bin/bash2# =============================================================================3#                  SP BOUCHER | INFRASTRUCTURE & AUTOMATION4#             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5# =============================================================================6#7# Project          : KA Maps Engine8# File             : server/pipeline/dem/build_dem.sh9# Module           : server10# Repository       : https://git.spboucher.ai/ka-maps-engine11# Created          : 2026-12-0112# Last Modified    : 2026-12-0113#14# Author           : Simon-Pierre Boucher15# Position         : Professor of Finance16# Institution      : Université du Québec en Outaouais (UQO)17# Organization     : SP Boucher18# Website          : https://spboucher.ai19# Git              : https://git.spboucher.ai20#21# Preferred Contact: support@spboucher.ai22# Technical Contact: dev@spboucher.ai23# Security/Admin   : admin@spboucher.ai24#25# Copyright (c) 202626# Simon-Pierre Boucher27# All rights reserved where applicable. This file is governed by the28# applicable project license, copyright notices and relevant law.29# Existing third-party rights and notices remain unaffected.30#31# License          : None specified (no license file in this repository)32#33# Do not embed credentials, private keys, access tokens,34# certificates or confidential personal information.35#36# =============================================================================37# END OF SP BOUCHER SOURCE HEADER38# =============================================================================3940# KA Maps — construction complète de la pyramide de relief (.ktr).41#   z8–z12 : Québec et voisinage (tuiles z8 x 71..87, y 70..92), MRDEM-30 DTM (RNCan) ; hors Canada : Copernicus GLO-30.42#   z0–z7  : monde, ETOPO 2022 30" (NOAA), altitudes négatives ramenées à 0.43# Sources attendues dans $SRC (voir fetch_dem.sh). Reprise : supprimer le fichier d'étape voulu dans $WORK.44set -euo pipefail45SRC=${SRC:-/var/lib/kamaps/src/dem}46WORK=${WORK:-$SRC/work}47OUT=${OUT:-/var/lib/kamaps/dem}48JOBS=${JOBS:-8}49HERE=$(cd "$(dirname "$0")" && pwd)50PY="nice -n 10 python3 $HERE/ktr_pyramid.py"51mkdir -p "$WORK" "$OUT"5253# --- Québec, z12 : grille de nœuds 69633 x 94209 (pas 38,2185 m en EPSG:3857) ---54if [ ! -f "$WORK/z12_f32.tif" ]; then55  nice -n 10 gdalwarp -overwrite -t_srs EPSG:3857 \56    -te -8922972.043155408 5478987.078224362 -6261702.247864568 9079515.077083448 -ts 69633 94209 \57    -r cubic -ot Float32 -dstnodata -32767 -multi -wo NUM_THREADS=$JOBS -wm 6000 --config GDAL_CACHEMAX 8000 \58    -co TILED=YES -co BIGTIFF=YES -co COMPRESS=ZSTD -co ZSTD_LEVEL=1 -co NUM_THREADS=$JOBS \59    "$SRC/glo30/glo30.vrt" "$SRC/mrdem/mrdem-30-dtm.tif" "$WORK/z12_f32.tif"60fi61[ -f "$WORK/z12.npy" ] || $PY grid "$WORK/z12_f32.tif" "$WORK/z12.npy" --z 12 --x0 1136 --y0 1120 --x1 1408 --y1 1488 --fill 062for z in 11 10 9 8; do63  [ -f "$WORK/z$z.npy" ] || $PY down "$WORK/z$((z+1)).npy" "$WORK/z$z.npy"64done65for z in 8 9 10 11 12; do66  [ -f "$OUT/meta/z$z.json" ] || $PY tiles "$WORK/z$z.npy" "$OUT" --jobs $JOBS67done6869# --- Monde, z7 : grille de nœuds 32769 x 32769 ---70if [ ! -f "$WORK/w7_f32.tif" ]; then71  nice -n 10 gdalwarp -overwrite -t_srs EPSG:3857 \72    -te -20038119.839015525 -20038119.839015525 20038119.839015525 20038119.839015525 -ts 32769 32769 \73    -r bilinear -ot Float32 -multi -wo NUM_THREADS=$JOBS -wm 4000 \74    -co TILED=YES -co BIGTIFF=YES -co COMPRESS=ZSTD -co ZSTD_LEVEL=1 \75    "$SRC/etopo/ETOPO_2022_v1_30s_N90W180_surface.tif" "$WORK/w7_f32.tif"76fi77[ -f "$WORK/w7.npy" ] || $PY grid "$WORK/w7_f32.tif" "$WORK/w7.npy" --z 7 --x0 0 --y0 0 --x1 128 --y1 128 --fill 0 --clamp-sea --wrap78for z in 6 5 4 3 2 1 0; do79  [ -f "$WORK/w$z.npy" ] || $PY down "$WORK/w$((z+1)).npy" "$WORK/w$z.npy" --wrap80done81for z in 0 1 2 3 4 5 6 7; do82  [ -f "$OUT/meta/z$z.json" ] || $PY tiles "$WORK/w$z.npy" "$OUT" --jobs $JOBS83done84echo DEM_DONE85python3 $HERE/write_meta.py "$OUT"86
Files main
Menu

Theme