Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix an issue when asking not to resample a GDAL tile iterator #1640

Merged
merged 1 commit into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()