update function

Change values in a file

Change values in a file

Change the contents of a file that is the data source of a SpatRaster. BE CAREFUL as you are overwriting values in an existing file.

## S4 method for signature 'SpatRaster' update(object, crs=FALSE, extent=FALSE)

Arguments

  • object: SpatRaster
  • crs: logical. Should the coordinate reference system be updated?
  • extent: logical. Should the extent be updated?

Returns

SpatRaster (invisibly)

Examples

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)
  • Maintainer: Robert J. Hijmans
  • License: GPL (>= 3)
  • Last published: 2025-02-26