exactextractr icon indicating copy to clipboard operation
exactextractr copied to clipboard

weighted_mean on raster with NAs

Open danielreispereira opened this issue 2 years ago • 2 comments

Trying to exact_extract() on a netcdf using a tiff as weights returns NaN for the majority of regions except for really small ones, suggesting that the function is failing if there are NAs on the input netcdf/Raster. Simple mean/median working flawlessly.

Is this the expected behavior? Since there is no "na.rm=TRUE" or the likes when using weighted_mean, how can I proceed if either the data or weights raster contain missing pixels?

danielreispereira avatar May 05 '22 02:05 danielreispereira

NA values in the primary raster are always ignored. NA values in the weighting raster propagate to the result. To avoid this, you can set the default_weight argument.

dbaston avatar May 05 '22 02:05 dbaston

Thanks, DBaston. The default behavior and "deafult_weight" was not obvious to me from the docs. Understood it now.

danielreispereira avatar May 05 '22 02:05 danielreispereira