Skip to content

Commit 70790c9

Browse files
committed
Improve compress ratio when saving GeoTIFFs
1 parent 31086f8 commit 70790c9

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

ext/GMTDGTLidarExt/GMTDGTLidarExt.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ module GMTDGTLidarExt
400400
ext_lc = use_mem ? ".tiff" : lowercase(splitext(outfile)[2])
401401
fmt_opts = ext_lc == ".nc" ? ["-of", "netCDF", "-co", "FORMAT=NC4", "-co", "COMPRESS=DEFLATE", "-co", "ZLEVEL=4"] :
402402
use_mem ? ["-of", "GTiff"] :
403-
["-of", "GTiff", "-co", "COMPRESS=DEFLATE", "-co", "PREDICTOR=2", "-co", "TILED=YES",
403+
["-of", "GTiff", "-co", "COMPRESS=ZSTD", "-co", "PREDICTOR=3", "-co", "TILED=YES",
404404
"-co", "BLOCKXSIZE=512", "-co", "BLOCKYSIZE=512"]
405405

406406
# Resolve output CRS: "geog" → EPSG:4326, bare digits → EPSG:<n>, anything else → pass directly
@@ -857,11 +857,11 @@ module GMTDGTLidarExt
857857
end
858858
859859
# Rewrite a GeoTIFF in-place with DEFLATE compression + tiling.
860-
# PREDICTOR=2 (horizontal differencing) improves ratio for integer/float data alike.
860+
# PREDICTOR=3 (horizontal differencing) improves ratio for integer/float data alike.
861861
function _compress_tiff(file_path::String)
862862
tmp = file_path * ".tmp.tiff"
863863
try
864-
GMT.gdaltranslate(file_path, ["-co", "COMPRESS=DEFLATE", "-co", "PREDICTOR=2",
864+
GMT.gdaltranslate(file_path, ["-co", "COMPRESS=DEFLATE", "-co", "PREDICTOR=3",
865865
"-co", "TILED=YES", "-co", "BLOCKXSIZE=512", "-co", "BLOCKYSIZE=512"]; save=tmp)
866866
mv(tmp, file_path; force=true)
867867
catch e
@@ -910,7 +910,7 @@ module GMTDGTLidarExt
910910
# Use GDAL /vsicurl/ to translate remote TIFF in one step (no download-then-recompress).
911911
if extension == ".tiff" && compress == "tif"
912912
GMT.gdaltranslate("/vsicurl/" * final_url,
913-
["-co", "COMPRESS=DEFLATE", "-co", "PREDICTOR=2", "-co", "TILED=YES",
913+
["-co", "COMPRESS=ZSTD", "-co", "PREDICTOR=3", "-co", "TILED=YES",
914914
"-co", "BLOCKXSIZE=512", "-co", "BLOCKYSIZE=512"]; save=file_path)
915915
elseif extension == ".tiff" && compress == "nc"
916916
GMT.gdaltranslate("/vsicurl/" * final_url,

0 commit comments

Comments
 (0)