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