Preserve non-spatial coords through reproject() and merge()#1455
Merged
brendancol merged 2 commits intomainfrom May 4, 2026
Merged
Preserve non-spatial coords through reproject() and merge()#1455brendancol merged 2 commits intomainfrom
brendancol merged 2 commits intomainfrom
Conversation
Closes #1454. reproject() and merge() rebuilt the output DataArray with only the y/x coords (and band coord on the 3D path). Other coords on the input were silently dropped: scalar coords like a single 'time' timestamp, non-dimension coords such as rioxarray's 'spatial_ref', and any extra dim coord unrelated to the spatial grid. Both functions now copy any coord whose dims do not include the rebuilt spatial dims. Coords aligned to ydim or xdim are still dropped because their values are stale after the grid is rebuilt. Also document in the reproject() and merge() Returns section that the output y coordinate is always emitted in descending order (top-down, north-up) regardless of the input direction. Adds TestCoordsPreservation covering scalar time coord, non-dim string coord, stale y-aligned coord drop, band coord round-trip, merge scalar coord, and y-descending output for numpy and dask.
Contributor
Author
|
@copilot resolve the merge conflicts in this pull request |
…coords-reproject-merge # Conflicts: # xrspatial/reproject/__init__.py Co-authored-by: brendancol <433221+brendancol@users.noreply.github.com>
Contributor
Resolved in c1f9dca. The conflict in Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
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.
Closes #1454.
Summary
reproject()andmerge()rebuilt the outputDataArraywith only the y/x (and band) coords. Scalar coords like a singletimetimestamp, non-dimension coords like rioxarray'sspatial_ref, and unrelated extra-dim coords were silently dropped.Returnssection of both docstrings that the output y coordinate is always emitted in descending order (top-down, north-up) regardless of the input direction. This matches the standard raster convention.Test plan
pytest xrspatial/tests/test_reproject.py -x(155 passed)TestCoordsPreservationclass covers:timecoord round-trip throughreproject()merge()