Extract columns sequentially to add to layers name of rasterbrick using setNames in R

Viewed 29

I have a data frame of two columns of 6 rows. I want to add the vectors of each column assigned to the layer names of 2 raster bricks sequentially. To explain

I have a list of raster brick (for this example 2) each raster files have six layers, and their names are shown as index.1, index.2, index.3.....index.6

data2 list of raster bricks

I have a list
list y for names

Now I am using pblapply to setNames of layers of the raster brick e.g,.

NewName <- pblapply(data2, function(file){ setNames(file, y[,1]})

using y[,1] sets the layers names of the 2 bricks to column 1 which is wrong as shown below.

Wrongly named raster layer

I want for rasterbrick 1 the layer names to be of 2003_07_ag412_mlrc , and for rasterBrick 2 to be 2003_08_ag412_mlrc. This is for a 2-set raster brick I have many for the last 20 years.

Any help is appreciated

0 Answers
Related