Skip to content

Commit

Permalink
Fix an issue when asking not to resample a GDAL tile iterator
Browse files Browse the repository at this point in the history
  • Loading branch information
manthey committed Sep 12, 2024
1 parent ec8c212 commit a1e9e68
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions sources/gdal/large_image_source_gdal/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
14 changes: 14 additions & 0 deletions test/test_source_gdal.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit a1e9e68

Please sign in to comment.