I have a
GeoTiff file with dimensions 300 x 300 and 8760 bands (hourly for one full year). I am testing some code that opens the file, updates ONE band and exits - but I am finding that the file size almost doubles when I exit the file, despite the new band being the same data type etc. Code is as follows:
I am creating the
GeoTiff file using the following creation options using many singular
gdal_merge.py -separate -co BIGTIFF=YES -co COMPRESS=DEFLATE -co PREDICTOR=1 -co TILED=YES -co BLOCKXSIZE=64 -co BLOCKYSIZE=64 -o block64.tif *.tif
The file size is 947MB.
I am then updating the file using the following code:
ds = gdal.Open("block64.tif", gdal.GA_Update) # Some simple operation to change band values arr = ds.GetRasterBand(11).ReadAsArray() / 2 ds.GetRasterBand(11).WriteArray(arr) ds.FlushCache() ds = None
The file size is now 1.9GB.
My preliminary conclusion is that the compression/creation options are not being applied once I've updated and exited the file. Is there any way to re-compress/reapply the options once I close the file?