I want to combine two (or more) raster bricks. Here's an example of what I want to do
library(raster)
r <- raster(ncol=40, nrow=20)
r[] <- rnorm(n=ncell(r))
b1 <- brick(x=c(r, r*2, r))
b2 <- brick(x=c(r, r*3, r))
b <- brick(b1, b2)
This example returns the following error.
Error in (function (cl, name, valueClass) : assignment of an object of class “RasterBrick” is not valid for @‘nlayers’ in an object of class “.MultipleRasterData”; is(value, "integer") is not TRUE
If I create stacks instead of bricks as follows
b1 <- stack(x=c(r, r*2, r))
b2 <- stack(x=c(r, r*3, r))
b <- brick(b1, b2)
I get the following error message
Error in if (values) { : argument is not interpretable as logical