[R-sig-Geo] summing rasters with a condition given by other rasters
Martin Brandt
martin.brandt at mailbox.org
Mon May 18 18:22:11 CEST 2015
Hi Eder,
yes, i tried to include na.rm:
sum_segment <- function(x, ...) {
mean(x[(x[1]+2):(x[2] + 2)], na.rm=TRUE)
}
but as long my stack contains any NA values, the function will not run with
calc:
> s <- calc(b, sum_segment)
Error in .calcTest(x[1:5], fun, na.rm, forcefun, forceapply) :
cannot use this function
or
> s <- calc(b, sum_segment, na.rm=T)
Error in .calcTest(x[1:5], fun, na.rm, forcefun, forceapply) :
cannot use this function. Perhaps add '...' or 'na.rm' to the function
arguments?
not sure how to make the function run and ignore all NAs..
--
View this message in context: http://r-sig-geo.2731867.n2.nabble.com/summing-rasters-with-a-condition-given-by-other-rasters-tp7588222p7588272.html
Sent from the R-sig-geo mailing list archive at Nabble.com.
More information about the R-sig-Geo
mailing list