Repository navigation
Add RasterIndex.get_indexer for vectorized point lookup - #100
Merged
Merged
Conversation
Return the int64 position of the cell that contains each point, or -1 for a point outside the extent, NaN or inf. Wraps on periodic axes; uses the full inverse affine for rotated/skewed transforms. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Motivation
xpublish-tiles needs a vectorized "which cell contains each point" lookup.
sel({"x": arr}, method="nearest")(0.2.4) wraps correctly on a periodic axis (global 1° grid, corners -180..180: 180.5, 539.5, -180.5 → 0, 359, 359), but:API
Follows
pandas.Index.get_indexer. Keys oflabelsare coordinate names (as forsel). Returns int64 positions keyed by dimension name, with the input shape;-1for a point outside the extent, NaN or inf.from_transformalready raisesNotImplementedError), so no wrap is needed.Edge convention
With
pthe corner-based pixel position (~index.transform()), a point is in celliifi <= p < i + 1, i.e.floor(p). A cell includes the edge at its lower position and excludes the one at its higher position; for a north-up raster that is the top edge included, the bottom edge excluded, and the raster's bottom edge is outside. Away from cell edges this equalssel(..., method="nearest")(which usesnp.round, round-half-to-even, at ties).🤖 Generated with Claude Code