subset-vector {terra}R Documentation

Subset of a SpatVector

Description

Select a subset of variables or records from a SpatVector.

Usage

## S4 method for signature 'SpatVector'
subset(x, subset, drop=FALSE)

Arguments

x

SpatVector

subset

logical expression indicating elements or rows to keep: missing values are taken as false

drop

logical. If TRUE, the geometries will be dropped, and a data.frame is returned

Value

SpatVector or, if drop=TRUE, a data.frame.

Examples

Run examples

f <- system.file("ex/lux.shp", package="terra")
v <- vect(f)
v[2:3,]
v[,2:3]
subset(v, v$NAME_1 == "Diekirch") 

[Package terra version 1.5-34 Index]