Common_Codin
Common_Codin

Reputation: 143

Separate layers in raster brick in R

New to R:
I have a raster brick that is holding 5 raster layers. How do I break this brick so each layer can be assigned to its own object and I can manipulate each individually?
Here is the info for the brick in case that helps.

>>eco.brick
class      : RasterBrick 
dimensions : 1920, 1440, 2764800, 5  (nrow, ncol, ncell, nlayers)
resolution : 0.008333333, 0.008333333  (x, y)
extent     : -71.00014, -59.00014, -29.99181, -13.99181  (xmin, xmax, ymin, ymax)
crs        : +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0 
source     : /tmp/RtmpdeDrSf/raster/r_tmp_2021-05-05_043302_2341_32265.grd 
names      : Central.Andes, Amazonian.Orinocan.Lowland, Eastern.Highlands, Gran.Chaco, Monte.Patagonian 
min values :             0,                          0,                 0,          0,                0 
max values :             1,                          1,                 1,          1,                1 

Upvotes: 0

Views: 772

Answers (1)

Robert Hijmans
Robert Hijmans

Reputation: 47146

Example data

library(raster)
b <- brick(system.file("external/rlogo.grd", package="raster"))

You can make a list of the layers like this

x <- as.list(b)

You can also assign each layer to a variable

r1 <- b[[1]]
r2 <- b[[2]]

Upvotes: 1

Related Questions