Skip to content

zonal stats: ensure chunksizes of zones and values are matching #574

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

Merged
merged 1 commit into from
Nov 17, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion xrspatial/zonal.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,9 @@ def stats(
values : xr.DataArray
values is a 2D xarray DataArray of numeric values (integers or floats).
The input `values` raster contains the input values used in
calculating the output statistic for each zone.
calculating the output statistic for each zone. In dask case,
the chunksizes of `zones` and `values` should be matching. If not,
`values` will be rechunked to be the same as of `zones`.

zone_ids : list of ints, or floats
List of zones to be included in calculation. If no zone_ids provided,
Expand Down Expand Up @@ -519,6 +521,11 @@ def stats(
)
else:
# dask case

# make sure chunksizes of `zones` and `values` are matching
if zones.chunks != values.chunks:
values.data = values.data.rechunk(zones.chunks)

stats_df = _stats_dask_numpy(
zones.data,
values.data,
Expand Down