Skip to content
New issue

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

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

Already on GitHub? # to your account

Specifying minimum coverage threshold for polygon? #108

Open
philament opened this issue Aug 13, 2024 · 1 comment
Open

Specifying minimum coverage threshold for polygon? #108

philament opened this issue Aug 13, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@philament
Copy link

Thanks for this really nice package. Here is a small feature request: I think it would be useful to have a simple way of including a minimum coverage threshold that is required for a function to return a valid value For example, I would like to calculate the raster means for a set of polygons but only if at least e.g. 80% of the area of a given polygon has non-NA values, otherwise the summary mean for this polygon should be NA. So maybe an argument such as min_cov_threshold = 0.8 or similar?

Anyway, I guess I could always use a user-defined function for this somehow but it might be more efficient to have something like this implemented with the predefined summary operations?

Also, if I have overlooked this possibility in the documentation or you have advice on how to implement this in an simple/efficient manner I am all ears.

@dbaston
Copy link
Member

dbaston commented Aug 13, 2024

For now, the cleanest way to do this is probably with a user-defined function.

With the Python version and CLI versions of exactextract you can provide arguments like default_value to individual operations directly. This would let you compute count both with and without NA values, from which you could figure out the NA percent in a post-processing step and decide if you want to retain the result or not.

This is shown in: https://github.com/isciences/exactextract/blob/afb834bc9f13d0b55952fe91e4cbc7c840c7d10f/python/tests/test_exact_extract.py#L475

Eventually I intend to unify the R and Python versions, making this syntax available in R as well.

@dbaston dbaston added the enhancement New feature or request label Aug 13, 2024
@dbaston dbaston changed the title Specifying minimum coverage threshold? Specifying minimum coverage threshold for polygon? Aug 13, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants