Created
July 30, 2016 12:18
-
-
Save lukasmartinelli/402a056168606a513d593fb34a94b80d to your computer and use it in GitHub Desktop.
Compress all DEM TIFF files in a directory in place
This file contains 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 | |
set -o errexit | |
set -o pipefail | |
set -o nounset | |
function compress_inplace() { | |
local filename="$1" | |
gdal_translate -co compress=lzw "$filename" "$filename.compressed" | |
rm "$filename" | |
mv "$filename.compressed" "$f" | |
} | |
function compress_files() { | |
local source_dir="$1" | |
for f in $source_dir/*.tif; do | |
compress_inplace "$f" | |
done | |
} | |
compress_files "$1" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment