Both filters are set on the layer and stay set. They apply to everything
read afterwards, including feature_count() and read_vector(). Passing
NULL clears the filter.
Arguments
- x
A GDALLayer object. A clause the driver cannot make sense of is not reported here: most drivers hand it to their own engine when the layer is next used, so a bad clause surfaces as a GDAL warning from
feature_count()orread_vector().- where
An SQL WHERE clause without the WHERE, or
NULLto clear it.- bbox
Numeric of length 4,
c(xmin, ymin, xmax, ymax)in the layer's own coordinates, orNULLto clear it.
Details
A spatial filter is what makes a large layer cheap: a driver with a spatial index uses it rather than reading every feature.
Examples
ds <- gdal_open(system.file("extdata/test.gpkg", package = "GDAL7"))
layer <- get_layer(ds, 1)
set_filter(layer, where = "population > 1e6")
feature_count(layer)
#> [1] 3
gdal_close(ds)