Repository navigation
Return the data pixel for point queries on pixel corners shared with nodata - #321
Open
DresdenGman wants to merge 1 commit into
Open
DresdenGman wants to merge 1 commit into
DresdenGman wants to merge 1 commit into
Conversation
Points falling exactly on a pixel edge or corner are equidistant from every pixel sharing the boundary. When the selected pixel was nodata, point_query returned None even if another touching pixel had data. For interpolate='nearest', check the other pixels that touch the point when the selected pixel is nodata and the point lies exactly on a pixel boundary. For bilinear's nodata fallback, examine the 2x2 cells in order of distance from the point instead of a single fixed cell. Fixes perrygeo#294
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.
Fixes #294.
Point queries on a pixel corner (or shared edge) are equidistant from every pixel touching the point, but the two interpolation modes picked one of them blindly:
nearestfloored its way to a single pixel andbilinear's masked fallback used round() on a single cell. If that pixel happened to be nodata, the query returned None even when another pixel sharing the corner had data, and the two modes disagreed with each other. On the example from the issue,nearestreturned[None, None, 1, None]andbilinear[None, 1, None, None].The fix only changes the case where the selected pixel has no data:
If every touching pixel is nodata the result stays None, and points not on a boundary are unaffected. The issue example now returns
[1, 1, 1, 1]under both modes.Tests: two new tests in
tests/test_point.py— one for the corner/edge regression (fails before, passes after), one guarding that all-nodata neighborhoods still return None. Full suite: 117 passed / 5 skipped before, 119 passed / 5 skipped after, no regressions; ruff check and format clean.