isciences / exactextractr

R package for fast and accurate raster zonal statistics
https://isciences.gitlab.io/exactextractr/
281 stars 26 forks source link

Implement named operation for categorical coverage fraction #75

Closed dbaston closed 2 years ago

dbaston commented 2 years ago

Provide a simplified means of summarizing the fraction of each polygon that is covered by a given raster value, i.e. a shortcut to the code shown in https://isciences.gitlab.io/exactextractr/articles/vig2_categorical.html#summary-functions

dbaston commented 2 years ago

A candidate version of this is available via remotes::install_git("https://gitlab.com/isciences/exactextractr", ref="add-frac"), which adds the summary operations frac and weighted_frac. I did some limited testing and it seems somewhat faster than the dplyr alternative demonstrated in the second vignette. It should certainly be more memory-efficient. The frac columns are added in "wide" form. I thought about long form, but that seemed awkward in the case where you are combining frac stats with others such as count.

dbaston commented 2 years ago

Implemented with 86f0be0439c335f97140aa0acfd192401de7917d