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