Skip to content

Return zero counts when a zone selects no pixels - #322

Merged
perrygeo merged 1 commit into
perrygeo:masterfrom
Sinkleberg:codex/empty-rasterization-counts
Dec 2, 2026
Merged

perrygeo merged 1 commit into
perrygeo:masterfrom
Sinkleberg:codex/empty-rasterization-counts

Conversation

@Sinkleberg

Copy link
Copy Markdown
Contributor

A polygon can fall between pixel centers and select no pixels. This returns zero for its nodata and NaN counts and avoids the NumPy warning. Cells that are actually selected still count, including nodata cells.

Closes #243. Tested with arrays and a real GeoTIFF. On Windows, 129 tests passed on Python 3.13 and 126 passed on 3.14 with three Fiona skips. Those runs used Affine 2.4 and Shapely 2.1. The latest versions already fail the baseline suite on deprecation warnings.

Prepared with Codex.

@perrygeo
perrygeo force-pushed the codex/empty-rasterization-counts branch from 1d07992 to ccd4c6e Compare December 2, 2026 14:25
@perrygeo

perrygeo commented Dec 2, 2026

Copy link
Copy Markdown
Owner

Great fix, @Sinkleberg - this has been bugging me for a while - I like your solution here.

I've rebased and force pushed to get the latest CI. Looks good. ✔️

@perrygeo
perrygeo merged commit d2df822 into perrygeo:master Dec 2, 2026
4 checks passed
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.

nodata when geometry has empty rasterization

2 participants