Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201945

r raster Can I combine two raster bricks directly?

$
0
0

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

Viewing all articles
Browse latest Browse all 201945

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>