Update y/x coords for mirror-flip TIFF orientations (#1537)#1539
Open
brendancol wants to merge 2 commits intomainfrom
Open
Update y/x coords for mirror-flip TIFF orientations (#1537)#1539brendancol wants to merge 2 commits intomainfrom
brendancol wants to merge 2 commits intomainfrom
Conversation
Orientations 2/3/4 in the TIFF Orientation tag (274) flip the array horizontally, both axes, or vertically. PR #1521 applied the buffer remap but left the y/x coord arrays computed from the un-flipped transform, so xarray label lookups against a georeferenced file returned the wrong pixel under any of those orientations. The fix updates the geo_info transform after the array remap so a displayed pixel and its geographic label point to the same location on the ground. PixelIsArea and PixelIsPoint both work; the unrotated transform is still preserved for ungeoreferenced files (coords stay on integer pixel indices).
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
read_to_arrayso xarray label lookups land on the right pixel for georeferenced files.N * step) and PixelIsPoint (shifts by(N-1) * step).Context
PR #1521 added the buffer remap for the Orientation tag (274). The 5-8 axis-swap branch already updates the transform (and warns). The 2/3/4 mirror branch was never wired up, so
_reader.pyflipped the array but kept the un-flipped origin and pixel-scale signs.da.sel(x=..., y=...)against the result returned whatever pixel originally lived at those coords -- not the pixel actually displayed there. See #1537 for a full reproducer.Test plan
pytest xrspatial/geotiff/tests/test_orientation.py -q(was 36, now 46 -- new tests cover sel-fidelity for orient 2/3/4 under PixelIsArea and PixelIsPoint, the coord-array first-element values, and the no-georef passthrough).pytest xrspatial/geotiff/tests/ -q --no-header --deselect xrspatial/geotiff/tests/test_features.py::TestPalette(942 passed; the deselected test failures are unrelated -- a Python 3.14 / matplotlib deepcopy regression).pytest xrspatial/geotiff/tests/test_planar_multiband.py xrspatial/geotiff/tests/test_lerc_valid_mask_gpu.py xrspatial/geotiff/tests/test_predictor2_big_endian_gpu_1517.py xrspatial/geotiff/tests/test_gpu_byteswap_1508.py xrspatial/geotiff/tests/test_gpu_strict_fallback_1516.py xrspatial/geotiff/tests/test_gpu_stripped_multiband.py -q(91 passed; CPU-only change, GPU path unaffected).Closes #1537.