Skip to content

Fix ascending-y grids: affine from coords, and rasterize/mask/coverage engines - #97

Merged
dcherian merged 2 commits into
mainfrom
fix-ascending-y-and-scalar-coords
Oct 6, 2026
Merged

dcherian merged 2 commits into
mainfrom
fix-ascending-y-and-scalar-coords

Conversation

@dcherian

@dcherian dcherian commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Supersedes #91 (thanks @mdsumner for the report and the fix).

  1. get_affine built a wrong affine from ascending-y coordinate arrays: the origin came from y[-1] but the scale stayed +dy. Now y[0] - dy/2 for either sign. test_assign_index_from_coords asserted the buggy value; fixed, plus a round-trip test.
  2. With a correct e > 0 affine, rusterize and exactextract (which assume north-up) gave y-flipped results. Before (1) they gave empty results. For e > 0, rasterize, geometry_mask and coverage now run on the y-flipped object and flip the result back. rasterio was already correct.

New tests: ascending-y for each engine, eager and chunked.

#92 is an xarray bug (CoordinateTransformIndexingAdapter._oindex_get keeps integer-indexed axes); fixed upstream in pydata/xarray#11679.

🤖 Generated with Claude Code

dcherian and others added 2 commits October 6, 2026 10:17
get_affine took the Y origin from y[-1] when dy > 0 but kept scale dy,
so materialized coords walked up from y.max(). Use y[0] - dy/2 for
either sign. test_assign_index_from_coords asserted the buggy value.

Supersedes #91

Co-Authored-By: Michael Sumner <mdsumner@gmail.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
rusterize and exactextract assume a north-up grid and gave flipped
results when affine.e > 0. For such grids, run on the y-flipped object
and flip the result back.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dcherian
dcherian merged commit 4ced0a9 into main Oct 6, 2026
11 checks passed
@dcherian
dcherian deleted the fix-ascending-y-and-scalar-coords branch October 6, 2026 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant