How to create a RasterBrick with band name?

Respected.

I have chirps daily rainfall data. totally 4262 data from 2008 to 2019.
i would like to create a rasterbrick that each raster should take a name for example chirps.1 chirps.2 chirps.3 up to chirps.4262.

could any one help me with the code?
i used the bellow code.

setwd("D:\Time Series\chirps\CDRR")
prsnncdr.fname<-list.files(path=getwd(), pattern="tif$")
st<- stack(prsnncdr.fname)
writeRaster(st, filename='FileNAme.grd', format="raster", overwrite=TRUE,options=c("INTERLEAVE=BAND","COMPRESS=LZW"))
##############################
now for giving each band a new name i created a datafram. with two column "Date" and "name2" in column name2 i PERSIANNcdr5km.1 up to PERSIANNcdr5km.4262

fnames<- paste0("Date", names(name2), format= ".tif")

and i am getting an error as bellow.
Error in paste0("Date", names(name2), format = ".tif") :
object 'name2' not found

Regards

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.