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

zonal_stats: to return a data array of calculated stats #589

Closed
thuydotm opened this issue Dec 1, 2021 · 0 comments · Fixed by #685
Closed

zonal_stats: to return a data array of calculated stats #589

thuydotm opened this issue Dec 1, 2021 · 0 comments · Fixed by #685
Labels
enhancement New feature or request

Comments

@thuydotm
Copy link
Contributor

thuydotm commented Dec 1, 2021

Should we provide an option for zonal stats, or write a new function to return a xarray.Dataset, where each layer is a xarray.DataArray of the calculated stats? For example:

# pseudo code
zones = array([
  [1, 1, 1, 1],
  [2, 2, 2,  2],
  [0, 0,  0, 2]
])
values = array([
  [1, 2, 3, 1],
  [8, 3, 3, 0],
  [0, 1, 0, 3]
])
results = zonal_stats(zones, values, stats=['count', 'max'])

Then results is a Dataset of 2 layers, one for count, and one for max.

>>> results.count.data
array([
  [4, 4, 4, 4],
  [5, 5, 5, 5],
  [3, 3, 3, 5]
])
>>> results.max.data
array([
  [3, 3, 3, 3],
  [8, 8, 8, 8],
  [1, 1, 1, 8]
])
@thuydotm thuydotm added the enhancement New feature or request label Dec 1, 2021
@thuydotm thuydotm changed the title zonal_stats: to return a dataset of calculated stats zonal_stats: to return a data array of calculated stats Mar 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant