Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
SRTM to tile

SRTM Contour to vector tile

Download SRTM Contour from OpenDEM Project


for y in `seq -w 0 85`;
  for x in `seq -w 0 180`;
    echo "$base_url/N${y}W${x}.zip" >> $urls
    echo "$base_url/S${y}W${x}.zip" >> $urls
    echo "$base_url/N${y}E${x}.zip" >> $urls
    echo "$base_url/S${y}E${x}.zip" >> $urls
mkdir files
cd files
aria2c -i ../urls.txt

Create working directory and move zip files

mkdir zips
cd zips
mv ../download/files/*.zip .

Unzip all

parallel unzip ::: *zip

Merge all files -single -f GPKG -o merged.gpkg */*.shp

Convert vector tile via tippecanoe (felt fork)

ogr2ogr -f GeoJSONSeq /vsistdout merged.gpkg | tippecanoe -Z9 -z11 -pf -M 2000000 -P -o contour.mbtiles -l contour -n "Contour line" -A "<a href=\"\" target=\"_blank\">&copy; OpenDEM</a>. License under ODbL."

SRTM to DEM raster tile

Download SRTM v3 from

wget -r -np -l 1 -A zip ""

create working direcotry and move all zip files

mkdir zips
cd zips
mv ../*.zip .
mv ../ .
mv ../*.zip .

Unzip all

for i in `ls *.zip`; do unzip $i; done

Create tiff file

gdalbuildvrt -a_srs EPSG:4326 -hidenodata all.vrt */*.hgt
gdal_translate -co compress=lzw -co BIGTIFF=YES -of GTiff all.vrt all.tiff --co="COMPRESS=LZW" --co="BIGTIFF=YES" --type=Float32 -A all.tiff --outfile=all_calc.tiff --calc="A*(A>0)" --NoDataValue=0

Setup venv and install rio-rgbify

sudo apt-get install python3-venv libpython3-dev libgdal-dev
python3 -m venv venv
source venv/bin/activate
pip install gdal
git clone
cd rio-rgbify
pip install -e '.[test]'

Run rio rgbify

rio rgbify -b -10000 -i 0.1 --format png --max-z 11 --min-z 5 all_calc.tiff dem.mbtiles
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment