Skip to content

Instantly share code, notes, and snippets.

@davidheyman
Created November 17, 2016 09:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidheyman/4e48d867cc3e1a552d4fc9b63d45925d to your computer and use it in GitHub Desktop.
Save davidheyman/4e48d867cc3e1a552d4fc9b63d45925d to your computer and use it in GitHub Desktop.
# create transparency band
for f in *tif;
do
gdal_translate -b 1 -ot Byte $f red.tif;
gdal_translate -b 2 -ot Byte $f green.tif;
gdal_translate -b 3 -ot Byte $f blue.tif;
gdal_translate -a_nodata none $f no.tif;
gdal_calc.py -A no.tif --outfile=mask.tif --calc="(A<=255)*255";
gdal_merge.py -separate -o ../ToCompress/$f red.tif green.tif blue.tif mask.tif;
sudo rm red.tif;
sudo rm green.tif;
sudo rm blue.tif;
sudo rm no.tif;
sudo rm mask.tif;
done
# compress using tiled jpeg
for f in *.tif
do
gdal_translate -co COMPRESS=JPEG -co TILED=YES $f ../ToUpload/$f;
done
# create overviews
for f in *.tif
do
gdaladdo --config COMPRESS_OVERVIEW JPEG --config INTERLEAVE_OVERVIEW PIXEL -r average $f 2 4 8 16 32 64;
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment