Last active
November 6, 2021 22:30
-
-
Save blacha/29b806963337927d83925e6814f03a9f to your computer and use it in GitHub Desktop.
Compare GDAL Compression
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| COMPRESSION=(zstd lzw deflate) | |
| TRANSLATE_ARGS="-co NUM_THREADS=ALL_CPUS -co PREDICTOR=2" | |
| CUID=$(id -u) | |
| CGID=$(id -g) | |
| # Run docker as the current user in the current diretory | |
| function docker_gdal() { | |
| docker run \ | |
| --user $CUID:$CGID \ | |
| --volume $PWD:$PWD \ | |
| --workdir $PWD \ | |
| --rm \ | |
| osgeo/gdal:ubuntu-small-latest $@ | |
| } | |
| INPUT_FILES=`ls -1 input/*.tif` | |
| mkdir -p output/ | |
| for inFile in $INPUT_FILES; do | |
| baseFileName=$(basename $inFile) | |
| echo "Processing $baseFileName " # $inFile ${baseFileName%.tif} | |
| for c in ${COMPRESSION[@]}; do | |
| echo " Compressing $baseFileName into $c" | |
| docker_gdal gdal_translate $inFile -of COG -co COMPRESS=$c $TRANSLATE_ARGS output/${baseFileName%.tif}.$c.cog.tiff &> /dev/null | |
| done | |
| done | |
| echo "Done..." | |
| echo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment