Skip to content

fix: snap float boundary segments to integer in all_touched rasterize (fixes #3384)#3387

Closed
gaoflow wants to merge 1 commit into
xarray-contrib:mainfrom
gaoflow:fix/rasterize-tile-float-snap
Closed

fix: snap float boundary segments to integer in all_touched rasterize (fixes #3384)#3387
gaoflow wants to merge 1 commit into
xarray-contrib:mainfrom
gaoflow:fix/rasterize-tile-float-snap

Conversation

@gaoflow

@gaoflow gaoflow commented Jun 18, 2026

Copy link
Copy Markdown

Under all_touched=True, the dask tile workers recompute
world-to-pixel coordinates per tile, which can nudge on-grid boundary
segments by a few ULPs (e.g. 15.0 → 14.999999999999996). The supercover
walk then misses the correct cell row/col, diverging from the eager path.

This snaps the float pixel coordinates to the nearest integer when they
are within 8× machine epsilon (relative to coordinate magnitude), making
the dask+numpy and dask+cupy backends match the eager path pixel-for-pixel.

Fixes all merge modes (first, last, max, min, sum, count). No effect on
all_touched=False or off-grid polygons.

@github-actions

Copy link
Copy Markdown

Hi @gaoflow, thanks for the PR!

Would you mind filing a quick New contributor introduction issue when you get a chance? It helps us point you at issues that fit what you'd like to work on. Most fields are optional.

Reviewing your PR doesn't depend on it, just a friendly nudge.

@brendancol

Copy link
Copy Markdown
Contributor

hey @gaoflow thanks for the PR. Unfortunately this PR is redundant with #3386

We are looking for new contributors, so if fill out a new contributor introduction issue and let's connect on more xarray-spatial stuff!

@brendancol brendancol closed this Jun 18, 2026
@brendancol brendancol self-requested a review June 18, 2026 22:24
@gaoflow

gaoflow commented Jun 18, 2026

Copy link
Copy Markdown
Author

Thanks for the heads-up. I missed #3386; this is redundant, so I’ll leave this closed. I’ll open the contributor introduction before picking up more xarray-spatial work.

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.

2 participants