isciences / exactextractr

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

Simpler area-based weighting for rasters in geographic coordinates #15

Closed dbaston closed 3 years ago

dbaston commented 4 years ago

It should be possible to use a flag to specify area-based weighting for rasters in geographic coordinates, rather than having to construct an input stack with previously-computed areas.

helsharif commented 4 years ago

Yes this enhancement would be greatly appreciated!

dbaston commented 3 years ago

I think this is sufficiently simplified by the ability to use weighting rasters with R summary functions, e.g., exact_extract(prec, brazil, function(x, cov, wt) weighted.mean(x, cov * wt), weights = area(prec)). At least, I'm doubtful that adding additional syntax would simplify a function that already has too many ways of calling it.