diff --git a/CHANGELOG.md b/CHANGELOG.md index b11bb9034..e8c1e9dee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ - Only list computable plot columns if there are other numeric columns ([#1634](../../pull/1634)) - List official yaml mime type for the multi source ([#1636](../../pull/1636)) +### Bug Fixes + +- Fix an issue when asking not to resample a GDAL tile iterator ([#1640](../../pull/1640)) + ## 1.29.9 ### Bug Fixes diff --git a/sources/gdal/large_image_source_gdal/__init__.py b/sources/gdal/large_image_source_gdal/__init__.py index ba484e9e5..2033eeb5e 100644 --- a/sources/gdal/large_image_source_gdal/__init__.py +++ b/sources/gdal/large_image_source_gdal/__init__.py @@ -879,6 +879,9 @@ def getRegion(self, format=(TILE_FORMAT_IMAGE, ), **kwargs): if not isinstance(format, (tuple, set, list)): format = (format, ) # The tile iterator handles determining the output region + if 'resample' in kwargs: + kwargs = kwargs.copy() + kwargs.pop('resample') iterInfo = self.tileIterator(format=TILE_FORMAT_NUMPY, resample=None, **kwargs).info # Only use gdal.Warp of the original image if the region has not been # styled. diff --git a/test/test_source_gdal.py b/test/test_source_gdal.py index 7e870357d..b606c9672 100644 --- a/test/test_source_gdal.py +++ b/test/test_source_gdal.py @@ -128,3 +128,17 @@ def testAlphaProjection(self): source = self.basemodule.open( imagePath) assert np.count_nonzero(source.getThumbnail(format='numpy')[0][:, :, 3] == 255) > 30000 + + def testGetTiledRegionWithoutResample(self): + imagePath = datastore.fetch('landcover_sample_1000.tif') + ts = self.basemodule.open(imagePath) + region, _ = ts.getRegion(output=dict(maxWidth=1024, maxHeight=1024), + encoding='TILED', resample=None) + result = self.basemodule.open(str(region)) + tileMetadata = result.getMetadata() + assert tileMetadata['bounds']['xmax'] == pytest.approx(2006547, 1) + assert tileMetadata['bounds']['xmin'] == pytest.approx(1319547, 1) + assert tileMetadata['bounds']['ymax'] == pytest.approx(2658548, 1) + assert tileMetadata['bounds']['ymin'] == pytest.approx(2149548, 1) + assert '+proj=aea' in tileMetadata['bounds']['srs'] + region.unlink()