Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

REF: use smallest int mask in rasterize #96

Merged
merged 1 commit into from
Feb 4, 2025

Conversation

martinfleis
Copy link
Member

Always use the smallest int mask in rasterize within zonal_stats. No need to expose anything as suggested in #95 as this always picks the smaller of int16 or int32.

Closes #95

@martinfleis martinfleis merged commit 131e6cb into xarray-contrib:main Feb 4, 2025
9 checks passed
@martinfleis martinfleis deleted the zonal_dtypes branch February 4, 2025 08:25
@@ -50,19 +51,32 @@ def _zonal_stats_rasterize(
crs = None

transform = acc._obj.rio.transform()
length = len(geometry)
dtype = np.int16 if length < np.iinfo(np.int16).max else np.int32

labels = features.rasterize(
Copy link
Contributor

@dcherian dcherian Feb 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another thing to consider is whether you want to make your own Grouper.

ds.groupby(xvec.GeometryGrouper(geometries))

or something .

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.

Allow custom dtypes and fills in _zonal_stats_rasterize
2 participants