Examples for 'terra::sds'


Create a SpatRasterDataset

Aliases: sds sds,missing-method sds,character-method sds,list-method sds,array-method sds,SpatRaster-method sds,stars-method sds,stars_proxy-method [<-,SpatRasterDataset,numeric,missing-method

Keywords: methods spatial

### ** Examples

s <- rast(system.file("ex/logo.tif", package="terra"))
x <- sds(s, s/2)
names(x) <- c("first", "second")
x
class       : SpatRasterDataset 
subdatasets : 2 
dimensions  : 77, 101 (nrow, ncol)
nlyr        : 3, 3 
resolution  : 1, 1  (x, y)
extent      : 0, 101, 0, 77  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=merc +lon_0=0 +k=1 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs 
source(s)   : logo.tif, memory 
names       : first, second 
length(x)
[1] 2
# extract the second SpatRaster
x[2]
class       : SpatRaster 
dimensions  : 77, 101, 3  (nrow, ncol, nlyr)
resolution  : 1, 1  (x, y)
extent      : 0, 101, 0, 77  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=merc +lon_0=0 +k=1 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs 
source      : memory 
names       :   red, green,  blue 
min values  :     0,     0,     0 
max values  : 127.5, 127.5, 127.5 
a <- array(1:9, c(3,3,3,3))
sds(a)
class       : SpatRasterDataset 
subdatasets : 3 
dimensions  : 3, 3 (nrow, ncol)
nlyr        : 3, 3, 3 
resolution  : 1, 1  (x, y)
extent      : 0, 3, 0, 3  (xmin, xmax, ymin, ymax)
coord. ref. :  
source(s)   : memory 

[Package terra version 1.5-34 Index]