split: Split

Description Usage Arguments Value Examples

Description

Split a SpatVector or SpatRaster

Usage

1
2
3
4
5
## S4 method for signature 'SpatRaster'
split(x, f)

## S4 method for signature 'SpatVector'
split(x, f)

Arguments

x

SpatRaster or SpatVector

f

If x is a SpatVector: a field (variable) name or a vector of the same length as x. If x is a SpatVector: a vector of the length nlyr(x)

Value

Same as x

Examples

1
2
3
4
5
6
v <- vect(system.file("ex/lux.shp", package="terra"))
x <- split(v, "NAME_1")

s <- rast(system.file("ex/logo.tif", package="terra"))   
y <- split(s, c(1,2,1))
sds(y)

Example output

terra version 0.9.8
Warning message:
In split.default(s, c(1, 2, 1)) :
  data length is not a multiple of split variable
class       : SpatDataSet 
subdatasets : 0 

terra documentation built on Jan. 13, 2022, 5:08 p.m.