auto-sync: 2026-05-13 12:30:01
This commit is contained in:
29
tasks/enduro-trails/scripts/download_kurviger.sh
Normal file
29
tasks/enduro-trails/scripts/download_kurviger.sh
Normal file
@@ -0,0 +1,29 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
cd /home/slin/enduro-trails/data/srtm
|
||||
BASE="https://srtm.kurviger.de/SRTM3/Eurasia"
|
||||
|
||||
echo 'Downloading from kurviger mirror...'
|
||||
for lat in 54 55 56; do
|
||||
for lon in 041 042 043 044 045 046; do
|
||||
f="N${lat}E${lon}"
|
||||
if [ -f "${f}.hgt" ]; then
|
||||
echo " EXISTS: ${f}"
|
||||
continue
|
||||
fi
|
||||
wget -q --timeout=60 "${BASE}/${f}.hgt.zip" -O "/tmp/${f}.hgt.zip" 2>/dev/null
|
||||
if [ -s "/tmp/${f}.hgt.zip" ]; then
|
||||
unzip -o -q "/tmp/${f}.hgt.zip" -d . && echo " OK: ${f} ($(du -h ${f}.hgt | cut -f1))" || echo " UNZIP FAIL: ${f}"
|
||||
rm -f "/tmp/${f}.hgt.zip"
|
||||
else
|
||||
echo " NOT FOUND: ${f}"
|
||||
rm -f "/tmp/${f}.hgt.zip"
|
||||
fi
|
||||
done
|
||||
done
|
||||
|
||||
echo ''
|
||||
echo "Total HGT: $(ls *.hgt | wc -l)"
|
||||
echo "New E041-E046 (N54-56):"
|
||||
ls N5[456]E04[1-6].hgt 2>/dev/null | sort
|
||||
46
tasks/enduro-trails/scripts/download_srtm.py
Normal file
46
tasks/enduro-trails/scripts/download_srtm.py
Normal file
@@ -0,0 +1,46 @@
|
||||
import urllib.request
|
||||
import zipfile
|
||||
import os
|
||||
import sys
|
||||
|
||||
SRTM_DIR = '/home/slin/enduro-trails/data/srtm'
|
||||
BASE_URL = 'https://srtm.kurviger.de/SRTM3/Eurasia'
|
||||
|
||||
tiles = []
|
||||
for lat in [54, 55, 56]:
|
||||
for lon in range(41, 47):
|
||||
tiles.append(f'N{lat}E{lon:03d}')
|
||||
|
||||
os.chdir(SRTM_DIR)
|
||||
count = 0
|
||||
|
||||
for tile in tiles:
|
||||
hgt = f'{tile}.hgt'
|
||||
if os.path.exists(hgt):
|
||||
print(f' EXISTS: {hgt}')
|
||||
continue
|
||||
|
||||
url = f'{BASE_URL}/{tile}.hgt.zip'
|
||||
tmp = f'/tmp/{tile}.hgt.zip'
|
||||
|
||||
try:
|
||||
print(f' Downloading {tile}...', end=' ', flush=True)
|
||||
urllib.request.urlretrieve(url, tmp)
|
||||
|
||||
if os.path.getsize(tmp) > 0:
|
||||
with zipfile.ZipFile(tmp, 'r') as z:
|
||||
z.extractall('.')
|
||||
os.remove(tmp)
|
||||
size = os.path.getsize(hgt) if os.path.exists(hgt) else 0
|
||||
print(f'OK ({size // 1024}KB)')
|
||||
count += 1
|
||||
else:
|
||||
print('EMPTY')
|
||||
os.remove(tmp)
|
||||
except Exception as e:
|
||||
print(f'FAIL: {e}')
|
||||
if os.path.exists(tmp):
|
||||
os.remove(tmp)
|
||||
|
||||
print(f'\nDownloaded: {count} new files')
|
||||
print(f'Total HGT: {len([f for f in os.listdir(".") if f.endswith(".hgt")])}')
|
||||
49
tasks/enduro-trails/scripts/download_srtm_v2.py
Normal file
49
tasks/enduro-trails/scripts/download_srtm_v2.py
Normal file
@@ -0,0 +1,49 @@
|
||||
import urllib.request
|
||||
import zipfile
|
||||
import os
|
||||
|
||||
SRTM_DIR = '/home/slin/enduro-trails/data/srtm'
|
||||
BASE_URL = 'https://srtm.kurviger.de/SRTM3/Eurasia'
|
||||
|
||||
tiles = []
|
||||
for lat in [54, 55, 56]:
|
||||
for lon in range(41, 47):
|
||||
tiles.append(f'N{lat}E{lon:03d}')
|
||||
|
||||
os.chdir(SRTM_DIR)
|
||||
count = 0
|
||||
|
||||
opener = urllib.request.build_opener()
|
||||
opener.addheaders = [('User-Agent', 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36')]
|
||||
urllib.request.install_opener(opener)
|
||||
|
||||
for tile in tiles:
|
||||
hgt = f'{tile}.hgt'
|
||||
if os.path.exists(hgt):
|
||||
print(f' EXISTS: {hgt}')
|
||||
continue
|
||||
|
||||
url = f'{BASE_URL}/{tile}.hgt.zip'
|
||||
tmp = f'/tmp/{tile}.hgt.zip'
|
||||
|
||||
try:
|
||||
print(f' Downloading {tile}...', end=' ', flush=True)
|
||||
urllib.request.urlretrieve(url, tmp)
|
||||
|
||||
if os.path.getsize(tmp) > 0:
|
||||
with zipfile.ZipFile(tmp, 'r') as z:
|
||||
z.extractall('.')
|
||||
os.remove(tmp)
|
||||
size = os.path.getsize(hgt) if os.path.exists(hgt) else 0
|
||||
print(f'OK ({size // 1024}KB)')
|
||||
count += 1
|
||||
else:
|
||||
print('EMPTY')
|
||||
os.remove(tmp)
|
||||
except Exception as e:
|
||||
print(f'FAIL: {e}')
|
||||
if os.path.exists(tmp):
|
||||
os.remove(tmp)
|
||||
|
||||
print(f'\nDownloaded: {count} new files')
|
||||
print(f'Total HGT: {len([f for f in os.listdir(".") if f.endswith(".hgt")])}')
|
||||
92
tasks/enduro-trails/scripts/regen_all.sh
Normal file
92
tasks/enduro-trails/scripts/regen_all.sh
Normal file
@@ -0,0 +1,92 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
echo '=== FULL REGENERATION (81 HGT files) ==='
|
||||
echo "Start: $(date)"
|
||||
|
||||
SRTM_DIR='/home/slin/enduro-trails/data/srtm'
|
||||
TERRAIN_DIR='/home/slin/enduro-trails/data/terrain'
|
||||
TMP='/tmp/regen_full'
|
||||
|
||||
rm -rf $TMP
|
||||
mkdir -p $TMP
|
||||
|
||||
echo ''
|
||||
echo '=== Step 1: Build VRT ==='
|
||||
find $SRTM_DIR -name '*.hgt' > $TMP/file_list.txt
|
||||
gdalbuildvrt -vrtnodata -32768 -overwrite -input_file_list $TMP/file_list.txt $TMP/srtm_all.vrt 2>&1
|
||||
echo "VRT: $(wc -l < $TMP/file_list.txt) files"
|
||||
gdalinfo -stats $TMP/srtm_all.vrt 2>&1 | grep STATISTICS
|
||||
|
||||
echo ''
|
||||
echo '=== Step 2: Generate HYPSO ==='
|
||||
cat > $TMP/color_ramp.txt << 'EOF'
|
||||
nv 0 0 0 0
|
||||
-100 0 0 0 0
|
||||
0 0 0 0 0
|
||||
1 57 151 105 255
|
||||
50 80 165 110 255
|
||||
100 120 180 100 255
|
||||
150 160 190 95 255
|
||||
200 139 176 96 255
|
||||
300 170 185 105 255
|
||||
500 189 188 115 255
|
||||
700 210 200 130 255
|
||||
1000 220 206 148 255
|
||||
1500 235 220 175 255
|
||||
2000 210 185 140 255
|
||||
2500 185 152 110 255
|
||||
3000 160 120 80 255
|
||||
4000 120 80 40 255
|
||||
5000 200 200 200 255
|
||||
EOF
|
||||
|
||||
gdaldem color-relief $TMP/srtm_all.vrt $TMP/color_ramp.txt $TMP/hypso.tif -alpha -of GTiff -co COMPRESS=LZW -co BIGTIFF=YES 2>&1
|
||||
echo "Hypso TIF: $(du -sh $TMP/hypso.tif | cut -f1)"
|
||||
|
||||
rm -rf ${TERRAIN_DIR}/hypso
|
||||
mkdir -p ${TERRAIN_DIR}/hypso
|
||||
gdal2tiles.py --zoom=5-12 --processes=4 --tilesize=256 --webviewer=none $TMP/hypso.tif ${TERRAIN_DIR}/hypso/ 2>&1
|
||||
echo "Hypso tiles: $(find ${TERRAIN_DIR}/hypso -name '*.png' | wc -l)"
|
||||
|
||||
echo ''
|
||||
echo '=== Step 3: Generate TRI ==='
|
||||
gdaldem TRI $TMP/srtm_all.vrt $TMP/tri_raw.tif -of GTiff -co COMPRESS=LZW -co BIGTIFF=YES -compute_edges 2>&1
|
||||
|
||||
cat > $TMP/tri_color.txt << 'EOF'
|
||||
nv 0 0 0 0
|
||||
0 0 0 0 0
|
||||
2 0 0 0 0
|
||||
3 255 255 100 60
|
||||
4 255 230 50 100
|
||||
5 255 200 0 140
|
||||
7 255 150 0 180
|
||||
10 255 100 0 200
|
||||
15 230 50 0 220
|
||||
20 200 0 0 235
|
||||
30 180 0 50 245
|
||||
50 150 0 100 255
|
||||
EOF
|
||||
|
||||
gdaldem color-relief $TMP/tri_raw.tif $TMP/tri_color.txt $TMP/tri_colored.tif -alpha -of GTiff -co COMPRESS=LZW -co BIGTIFF=YES 2>&1
|
||||
echo "TRI TIF: $(du -sh $TMP/tri_colored.tif | cut -f1)"
|
||||
|
||||
rm -rf ${TERRAIN_DIR}/tri
|
||||
mkdir -p ${TERRAIN_DIR}/tri
|
||||
gdal2tiles.py --zoom=5-12 --processes=4 --tilesize=256 --webviewer=none $TMP/tri_colored.tif ${TERRAIN_DIR}/tri/ 2>&1
|
||||
echo "TRI tiles: $(find ${TERRAIN_DIR}/tri -name '*.png' | wc -l)"
|
||||
|
||||
echo ''
|
||||
echo '=== Stats ==='
|
||||
echo "Hypso:"
|
||||
for z in 8 9 10 11 12; do
|
||||
echo " zoom $z: $(find ${TERRAIN_DIR}/hypso/$z -name '*.png' -size +400c 2>/dev/null | wc -l) non-empty"
|
||||
done
|
||||
echo "TRI:"
|
||||
for z in 8 9 10 11 12; do
|
||||
echo " zoom $z: $(find ${TERRAIN_DIR}/tri/$z -name '*.png' -size +400c 2>/dev/null | wc -l) non-empty"
|
||||
done
|
||||
|
||||
echo ''
|
||||
echo "=== DONE ==="
|
||||
echo "End: $(date)"
|
||||
Reference in New Issue
Block a user