Learn R Programming

terra (version 1.9-11)

query: Query a SpatVectorProxy object

Description

Query a SpatVectorProxy to extract a subset

Usage

# S4 method for SpatVectorProxy
query(x, start=1, n=nrow(x), vars=NULL, where=NULL, 
    extent=NULL, filter=NULL, sql=NULL, dialect="", what="")

Arguments

Value

SpatVector

See Also

vect

Examples

Run this code
f <- system.file("ex/lux.shp", package="terra")
v <- vect(f, proxy=TRUE)
v

x <- query(v, vars=c("ID_2", "NAME_2"), start=5, n=2)
x

query(v, vars=c("ID_2", "NAME_1", "NAME_2"), where="NAME_1='Grevenmacher' AND ID_2 > 6")

## with an extent
e <- ext(5.9, 6.3, 49.9, 50) 
x <- query(v, extent=e)

## with polygons
p <- as.polygons(e)
x <- query(v, filter=p)
x

Run the code above in your browser using DataLab