inplace {terra} | R Documentation |
Change values in-place
Description
These "in-place" replacement methods assign new value to an object without making a copy. That is efficient, but if there is a copy of the object that you made by standard assignment (e.g. with y <- x
), that copy is also changed.
set.names
is the in-place replacement version of names<-
.
set.ext
is the in-place replacement version of ext<-
set.values
is the in-place replacement version of [<-
.
set.cats
is the in-place replacement version of categories
set.crs
is the in-place replacement version of crs<-
Usage
## S4 method for signature 'SpatRaster'
set.names(x, value, index=1:nlyr(x), validate=FALSE)
## S4 method for signature 'SpatRasterDataset'
set.names(x, value, index=1:length(x), validate=FALSE)
## S4 method for signature 'SpatVector'
set.names(x, value, index=1:ncol(x), validate=FALSE)
## S4 method for signature 'SpatRaster'
set.ext(x, value)
## S4 method for signature 'SpatVector'
set.ext(x, value)
## S4 method for signature 'SpatRaster'
set.crs(x, value)
## S4 method for signature 'SpatVector'
set.crs(x, value)
## S4 method for signature 'SpatRaster'
set.values(x, cells, values, layer=0)
## S4 method for signature 'SpatRaster'
set.cats(x, layer=1, value, active=1)
## S4 method for signature 'SpatRaster'
set.RGB(x, value, type="rgb")
Arguments
x |
SpatRaster |
value |
character for |
index |
positive integer indicating layer(s) to assign a name to |
validate |
logical. Make names valid and/or unique? |
cells |
cell numbers or missing |
values |
replacement values or missing to load all values into memory |
layer |
positive integer(s) indicating to which layer(s) to you want to assign these categories or to which you want to set these values. A number < 1 indicates "all layers" |
active |
positive integer indicating the active category (column number in |
type |
character. The color space. One of "rgb" "hsv", "hsi" and "hsl" |
Value
logical (invisibly)
Examples
s <- rast(ncols=5, nrows=5, nlyrs=3)
x <- s
names(s)
names(s) <- c("a", "b", "c")
names(s)
names(x)
x <- s
set.names(s, c("e", "f", "g"))
names(s)
names(x)
set.ext(x, c(0,180,0,90))
f <- system.file("ex/elev.tif", package="terra")
r <- rast(f)
#values from file to memory
set.values(r)
# change values
set.values(r, 1:1000, 900)