Skip to contents

Single bracket '[' refers to indices and names within the 'VirtualArray'-class object. Use double brackets to replace layers based on their names (in the @stack). Object types of the same kind class can be used to replace values in 'XArray'-class objects. 'SpatRaster'-class objects can be used to replace values in 'RasterArray'-class objects. Classes inheriting from 'sf' can be used with 'SfArray'-class objects.

Usage

# S4 method for VirtualArray,ANY,ANY,logical
[(x, i, j, ...) <- value

# S4 method for RasterArray,ANY,ANY,SpatRaster
[(x, i, j, ...) <- value

# S4 method for SfcArray,ANY,ANY,sfc
[(x, i, j, ...) <- value

# S4 method for SfArray,ANY,ANY,sf
[(x, i, j, ...) <- value

Arguments

x

VirtualArray-class object.

i

subscript of the first dimension(rows) or vector-like subsetting.

j

subscript of the second dimension (columns).

...

subscript of additional dimensions.

value

A same class object as x.

Value

The function has no return value.

Examples

ex <- rastex() 
# replace third element with missing value
ex[3] <- NA
# duplicate first element and make it the second too
ex[2] <- ex[1]
ex
#> class         : RasterArray
#> Element properties: 
#> - class       : SpatRaster
#> - dimensions  : 180, 360 (nrow, ncol)
#> - resolution  : 1, 1 (x, y)
#> - extent      : -180, 180, -90, 90 (xmin, xmax, ymin, ymax)
#> - coord.ref.  : WGS 84
#> Array properties: 
#> - dimensions  : 6  (vector)
#> - num. layers : 5
#> - missing     : 1
#> - proxy:
#>          a         b         c         d         e         f 
#> "layer_1" "layer_1"        NA "layer_4" "layer_5" "layer_6" 
#>