Skip to content

Commit

Permalink
fixes #1588
Browse files Browse the repository at this point in the history
  • Loading branch information
rhijmans committed Jan 2, 2025
1 parent 9ecebc6 commit 001afdb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
3 changes: 2 additions & 1 deletion R/update.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@

setMethod("update", signature(object="SpatRaster"),
function(object, names=FALSE, crs=FALSE, extent=FALSE) {
function(object, crs=FALSE, extent=FALSE) {
opt <- spatOptions()
names <- FALSE
ok <- object@pntr$update_meta(names, crs, extent, opt)
messages(object, "update")
invisible(object)
Expand Down
6 changes: 2 additions & 4 deletions man/update.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@ Change the contents of a file that is the data source of a SpatRaster. BE CAREFU
}

\usage{
\S4method{update}{SpatRaster}(object, names=FALSE, crs=FALSE, extent=FALSE)
\S4method{update}{SpatRaster}(object, crs=FALSE, extent=FALSE)
}

\arguments{
\item{object}{SpatRaster}
\item{names}{logical. Should the names be updated?}
\item{crs}{logical. Should the coordinate reference system be updated?}
\item{extent}{logical. Should the extent be updated?}
}
Expand All @@ -28,11 +27,10 @@ Change the contents of a file that is the data source of a SpatRaster. BE CAREFU
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)
update(x, crs=TRUE, extent=TRUE)

rast(fname)
}
Expand Down

0 comments on commit 001afdb

Please sign in to comment.