Repository navigation
fix(s2): compute spatial:bbox and spatial:transform from pixel edges - #275
Merged
Merged
Conversation
Coordinates are pixel centres, but spatial:registration is "pixel", so the bbox and the transform origin must be at the outer pixel edges. Calculate the bbox in one helper and use it for each level and for the multiscale parent, so that the parent footprint agrees with its levels. Fixes #266 Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 task done
Merged
3 of 4 tasks
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 #266.
The S2 converter calculated
spatial:bboxand thespatial:transformorigin from the x/y coordinates. These coordinates are pixel centres, but the groups declarespatial:registration: "pixel". The footprint was therefore half a pixel too small on each side.Changes
_transform_from_coordinates: the origin is now the outer pixel edge. It now agrees withrio.transform, so_preferred_spatial_transformcan select the rio transform again._bbox_from_coordinates: calculates the bbox from that transform and the grid shape. If an axis has fewer than 2 pixels, it uses the coordinate extent, as before.write_geo_metadata(each level) andadd_multiscales_metadata_to_parent(pyramid parent) both use the new helper, so the parent bbox now agrees with its finest level.spatial:bboxfor one level and for the parent.Notes for reviewers
cpm-geozarrhas the same code in the same three places. A cherry-pick of this commit is necessary there (Fix correct bounds for spatial:bbox attributes due to mismatch/offset between coords and bounds #266 lists that branch).conversion/geozarr.pyusesrio.bounds()ands3_olci_optimizationalready uses edges, so they need no change.🤖 Generated with Claude Code