Skip to content

Zonal functions accept vector zones directly#999

Merged
brendancol merged 2 commits into
masterfrom
issue-998
Mar 10, 2026
Merged

Zonal functions accept vector zones directly#999
brendancol merged 2 commits into
masterfrom
issue-998

Conversation

@brendancol
Copy link
Copy Markdown
Contributor

@brendancol brendancol commented Mar 10, 2026

Closes #998

Summary

  • stats(), crosstab(), apply(), and crop() now accept a GeoDataFrame or list of (geometry, value) pairs as the zones argument. When vector input is detected, rasterize() is called internally using the values raster as the grid template.
  • Adds column parameter (names the zone-ID column in a GeoDataFrame) and rasterize_kw (forwarded to rasterize(), e.g. {'all_touched': True}).
  • Existing raster-input behavior is unchanged.

Test plan

  • TestVectorZones class (10 tests): GeoDataFrame parity with manual rasterize, list-of-pairs, error cases (missing column, column with pairs), accessor, crosstab, apply, crop, rasterize_kw forwarding, raster zones still work
  • All 106 existing zonal tests still pass

stats(), crosstab(), apply(), and crop() now accept GeoDataFrames or
list-of-(geometry, value) pairs as the zones argument. When vector
input is detected, rasterize() is called internally using the values
raster as the template. Adds column and rasterize_kw parameters.
Document column and rasterize_kw parameters in stats(), crosstab(),
apply(), and crop() docstrings. Add vector zones section to the
3_Zonal user guide notebook with GeoDataFrame, list-of-pairs,
crosstab, and rasterize_kw examples.
@github-actions github-actions Bot added the performance PR touches performance-sensitive code label Mar 10, 2026
@brendancol brendancol merged commit 2ebab21 into master Mar 10, 2026
11 checks passed
@brendancol brendancol deleted the issue-998 branch May 4, 2026 13:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance PR touches performance-sensitive code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Zonal functions should accept vector zones directly

1 participant