Fix read_geotiff_gpu dim mismatch on stripped multi-band TIFFs#1525
Merged
brendancol merged 1 commit intoxarray-contrib:mainfrom May 9, 2026
Merged
Conversation
The stripped fallback inside read_geotiff_gpu hardcoded dims=['y','x']
even when the CPU read returned a 3-D (y, x, band) array for multi-band
stripped files. That raised a ValueError about dimension count.
Mirror the tiled-branch logic: pick ('y', 'x', 'band') with a band coord
when the CPU array is 3-D, otherwise keep the 2-D ('y', 'x') path.
Adds xrspatial/geotiff/tests/test_gpu_stripped_multiband.py covering the
3-band uint8, 2-band uint16, and single-band sanity cases. Audit pass
following PRs xarray-contrib#1523/xarray-contrib#1524.
6 tasks
There was a problem hiding this comment.
Pull request overview
This PR fixes a shape/dimension mismatch in read_geotiff_gpu for stripped (non-tiled) multi-band GeoTIFFs. Previously, the stripped-file branch always constructed a 2-D DataArray with dims=['y', 'x'], even when the CPU reader returned a 3-D (y, x, band) array, causing an xarray ValueError. The change makes the stripped path mirror the already-correct tiled path behavior.
Changes:
- Update
read_geotiff_gpustripped-file fallback to setdims=('y','x','band')and add abandcoord when the uploaded GPU array is 3-D. - Add GPU regression tests covering stripped multi-band round-trips (uint8/uint16) and ensuring single-band remains 2-D.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
xrspatial/geotiff/__init__.py |
Fix stripped (non-tiled) read_geotiff_gpu DataArray construction to handle 3-D multi-band arrays consistently with the tiled path. |
xrspatial/geotiff/tests/test_gpu_stripped_multiband.py |
Add regression tests for stripped multi-band GPU reads and a sanity check for single-band behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The stripped-fallback branch in
read_geotiff_gpuhardcodeddims=['y','x']even when the underlying CPU reader returned a 3-D(y, x, band)array for multi-band stripped files. That raisedValueError: dimensions ('y', 'x') must have the same length as the number of data dimensions, ndim=3.The fix mirrors the tiled-branch logic already used a few lines later in the same function: when
arr_gpu.ndim == 3use('y', 'x', 'band')and add abandcoord; otherwise keep('y', 'x').Reproducer
Tests
xrspatial/geotiff/tests/test_gpu_stripped_multiband.pycovers:Tests use the same
cupy + CUDAskip pattern astest_gpu_byteswap_1508.py.Context
Audit pass following PRs #1523 / #1524 on the geotiff GPU read path.
Test plan