-
Notifications
You must be signed in to change notification settings - Fork 9
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
ENH: support exactextract as a method in zonal_stats #68
Conversation
Thanks for this! Regarding the stats, I think it is fine to document the differences when using |
Can you include tests and that documentation? |
Yes l'll take care of that |
I've just added a test for exactextract. Since exactextract performs statistics based on pixel fractions, the results differ from those of rasterization and iteration. I've maintained the same test functions and data, but added an if-statement specifically for the exactextract method. This introduces only one condition and does not significantly increase the code's complexity. To avoid complexity, we could create a separate test function for exactextract and use different data. However, I believe this isn't necessary given that we're only adding one condition. The docs will follow soon :) |
it was a typo. I used same values Co-authored-by: Martin Fleischmann <[email protected]>
I am fine with how the way you did tests, keep it. |
Now it should be ready :) |
I pushed my suggestions directly now. I am wondering - I know that exactextract only supports DataArray but shall we make an effort and return a Dataset if the input is a Dataset? As shown in the notebook, we now return DataArray, which is inconsistent with the other methods. Can we try to convert it so the input type matches the output type? |
Yes it is better to match the types. I'll add a part to handle it |
I reengineered the code to match the input/output types and modified the pytests accordingly. |
This is great! One final request, can we pass through attributes as we do with rasterio-based zonal_stats? At that point I think we get the parity and I'd be happy to merge. Thanks a ton for working on this! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Now we just need a proper release of exactextract
😅
This is an initial implementation for exactextract.
exactextract expects the statistical input to be an object of a Python class named 'operation' defined within the package. It utilizes a built-in method to construct these objects if the input is a string or callable. However, this built-in method does not support all callables (such as np.mean, ...), and strings like 'quantile' should follow this pattern: 'quantile(q=0.33)'. I've added a check function for the statistical input to use when the method is exactextract, but I'm unsure if this is the best option or if it should simply be added to the documentation.