Honor per-raster nodata sentinels in merge()#1449
Merged
brendancol merged 2 commits intomainfrom May 4, 2026
Merged
Conversation
merge() previously detected nodata only from the first raster and reused that sentinel for every other input. Rasters with a different sentinel had their invalid pixels passed through reprojection as real data, producing silently wrong results. Detect each raster's own sentinel, canonicalize to NaN before the strategy merge, then convert back to the user-requested output nodata. Affects both _merge_inmemory and the dask _merge_block_adapter path.
Contributor
Author
|
@copilot resolve the merge conflicts in this pull request |
…ization Co-authored-by: brendancol <433221+brendancol@users.noreply.github.com>
Contributor
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 #1448.
Summary
merge()only detected the first raster's nodata sentinel and reused it for every other input, so rasters with a different sentinel had their invalid pixels passed through reprojection as real data. The mosaic looked fine but contained wrong numerical values.Fix
raster_infosloop, independent of the user-supplied outputnodata.nodataif that is not NaN.Applied in both the in-memory path (
_merge_inmemory) and the dask path (_merge_block_adapter/_merge_dask).Test plan
pytest xrspatial/tests/test_reproject.py(139 passed)TestMergeMixedNodataclass covers:meanstrategy (verifies zeros are not folded into averages)nodata=-9999output