s <- rast(system.file("ex/logo.tif", package="terra"))
fname <- paste0(tempfile(), ".tif")
x <- writeRaster(s, fname)
names(x) <- c("A", "B", "C")
ext(x) <- ext(x) + 1
crs(x) <- "+proj=utm +zone=1"
update(x, names=TRUE, crs=TRUE, extent=TRUE)
rast(fname)
Run the code above in your browser using DataLab