isciences / exactextractr

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

Weighting example gives error #19

Closed RS-eco closed 4 years ago

RS-eco commented 4 years ago

I was trying to implement your weighting example, but doing so get an error message: I ran the following code:

library(raster)
library(sf)
library(exactextractr)

# Pull municipal boundaries for Brazil
brazil <- st_as_sf(getData('GADM', country='BRA', level=2))

# Pull gridded precipitation data
prec <- getData('worldclim', var='prec', res=10)[[12]]

# Weighting
brazil$mean_prec_weighted <- exact_extract(prec, brazil, 'weighted_mean', weights=area(prec))

And receive the following error:

Error in .local(x, y, ...) : exact_extract was called with a named summary operation thatdoes not accept additional arguments ...

dbaston commented 4 years ago

The weighting method is implemented in the current master branch, but has not yet been released to CRAN. Are you working with the current master ?

RS-eco commented 4 years ago

Sorry, I didn't consider that. Perfect, now it works. ;)