Message-ID: <1431257864941-7588226.post@n2.nabble.com>
Date: 2015-05-10T11:37:44Z
From: Martin
Subject: summing rasters with a condition given by other rasters
In-Reply-To: <930D04EF-2AAC-43C5-8F50-48E109E587E4@bigelow.org>
Hi Ben,
many thanks for the detailed answer. The code works fine, but when I use
rasters for eos and sos instead of numbers, i get an error:
b <- brick(system.file("external/rlogo.grd", package="raster"))
b <- addLayer(b,b,b)
b
sos <- raster(system.file("external/rlogo.grd", package="raster"))
eos <- raster(system.file("external/rlogo.grd", package="raster"))
sum_segment <- function(x, from = sos, to = eos, ...) {
sum(x[from:to],...)
}
s <- calc(b, sum_segment)
Error in .calcTest(x[1:5], fun, na.rm, forcefun, forceapply) :
cannot use this function
am I doing something wrong?
--
View this message in context: http://r-sig-geo.2731867.n2.nabble.com/summing-rasters-with-a-condition-given-by-other-rasters-tp7588222p7588226.html
Sent from the R-sig-geo mailing list archive at Nabble.com.