Skip to content

Commit

Permalink
Merge branch 'bugfix/fix_crea_options' into 'master'
Browse files Browse the repository at this point in the history
Bugfix/fix crea options

See merge request danschef/arosics!32
  • Loading branch information
Daniel Scheffler committed Mar 10, 2023
2 parents 33a60fb + 01f2341 commit da25b6b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
1 change: 1 addition & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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).


Expand Down
7 changes: 2 additions & 5 deletions arosics/DeShifter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down
16 changes: 16 additions & 0 deletions tests/test_COREG.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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
Expand Down

0 comments on commit da25b6b

Please sign in to comment.