Created
October 29, 2022 12:17
-
-
Save allixender/e33ac8bec2bd8484ca7329154839a729 to your computer and use it in GitHub Desktop.
Make proper GeoTiff COG with overviews through GDAL
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 | |
# https://trac.osgeo.org/gdal/wiki/CloudOptimizedGeoTIFF | |
input=$1 | |
output=$2 | |
oversample="nearest" # or nearest, average | |
gdal_translate $1 interm_step1.tif -co TILED=YES -co COMPRESS=DEFLATE | |
gdaladdo -r $oversample interm_step1.tif 2 4 8 16 32 | |
gdal_translate interm_step1.tif $2 -co TILED=YES -co COMPRESS=LZW -co COPY_SRC_OVERVIEWS=YES \ | |
-co BIGTIFF=IF_SAFER -co BLOCKXSIZE=512 -co BLOCKYSIZE=512 --config GDAL_TIFF_OVR_BLOCKSIZE 512 | |
rm interm_step1.tif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment