diff --git a/HISTORY.rst b/HISTORY.rst index e0a9695..0c56d65 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -5,6 +5,7 @@ History 1.8.1 (2023-03-10) ------------------ +* Fixed https://github.com/GFZ/arosics/issues/20 (out_crea_options has no effect) (!32). * Updated copyright (!33). diff --git a/arosics/DeShifter.py b/arosics/DeShifter.py index 627654d..64b851f 100644 --- a/arosics/DeShifter.py +++ b/arosics/DeShifter.py @@ -364,9 +364,6 @@ def correct_shifts(self) -> collections.OrderedDict: self.GeoArray_shifted = out_geoArr - if self.path_out: - out_geoArr.save(self.path_out, fmt=self.fmt_out) - else: # FIXME equal_prj==False ist noch NICHT implementiert """RESAMPLING NEEDED""" # FIXME avoid reading the whole band if clip_extent is passed @@ -411,8 +408,8 @@ def correct_shifts(self) -> collections.OrderedDict: self.is_shifted = True self.is_resampled = True - if self.path_out: - out_geoArr.save(self.path_out, fmt=self.fmt_out, creationOptions=self.out_creaOpt) + if self.path_out: + out_geoArr.save(self.path_out, fmt=self.fmt_out, creationOptions=self.out_creaOpt) # validation if not is_coord_grid_equal(self.updated_gt, *self.out_grid, tolerance=1.e8): diff --git a/tests/test_COREG.py b/tests/test_COREG.py index 1c0f671..d42703b 100644 --- a/tests/test_COREG.py +++ b/tests/test_COREG.py @@ -36,6 +36,7 @@ from .cases import test_cases from arosics import COREG from geoarray import GeoArray +from osgeo import gdal from py_tools_ds.geo.projection import EPSG2WKT @@ -377,6 +378,21 @@ def test_correct_shifts_with_resampling(self): self.assertFalse(np.array_equal(CR.shift[:], CR.deshift_results['arr_shifted'])) self.assertTrue(np.array_equal(np.array(CR.shift.gt), np.array(CR.deshift_results['updated geotransform']))) + def test_correct_shifts_gdal_creation_options(self): + """Test if the out_crea_options parameter works.""" + kw = self.coreg_kwargs.copy() + kw['fmt_out'] = "GTiff" + kw['out_crea_options'] = ["COMPRESS=DEFLATE", "BIGTIFF=YES", "ZLEVEL=9", "BLOCKXSIZE=512", "BLOCKYSIZE=512"] + + # in case the output data is not resampled + self.run_shift_detection_correction(self.ref_path, self.tgt_path, **kw) + self.assertTrue('COMPRESSION=DEFLATE' in gdal.Info(kw['path_out'])) + + # in case the output data is resampled + kw['align_grids'] = True + self.run_shift_detection_correction(self.ref_path, self.tgt_path, **kw) + self.assertTrue('COMPRESSION=DEFLATE' in gdal.Info(kw['path_out'])) + if __name__ == '__main__': import pytest