Skip to content

Instantly share code, notes, and snippets.

@n-a-t-e
Created December 5, 2022 20:36
Show Gist options
  • Save n-a-t-e/47764745d8a8b8c761a09116a9335a09 to your computer and use it in GitHub Desktop.
Save n-a-t-e/47764745d8a8b8c761a09116a9335a09 to your computer and use it in GitHub Desktop.
NetCDF to XYZ tiles using GDAL and Docker
#!/bin/bash
docker run -it -v `pwd`/tiles:/tiles --name gdal --rm osgeo/gdal /bin/bash -c "
wget https://hpfx.collab.science.gc.ca/20221201/WXO-DD/model_ciops/salish-sea/500m/00/001/20221201T00Z_MSC_CIOPS-SalishSea_SeaSfcHeight_Sfc_LatLon0.008x0.005_PT001H.nc
echo -e '-2 red\n0 50 180 50\n2 blue\nnv 0 0 0 0' > colors.txt
gdal_translate -a_nodata 10000000000 *.nc out.tif
gdaldem color-relief -alpha out.tif colors.txt out.tif
gdal_translate -of VRT -ot Byte -scale out.tif temp.vrt
time gdal2tiles.py --process=8 --zoom 0-11 temp.vrt --tilesize=256 --xyz
cp -r temp/* /tiles"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment