gpkg_ogr_query(): an alias for gpkg_query(..., ogr=TRUE)

gpkg_query(x, query, ogr = FALSE, ...)

gpkg_ogr_query(x, query, ...)

Arguments

x

A geopackage object

query

character. An SQLite/Spatialite/GeoPackage query. The query argument is forwarded to sql argument when ogr=TRUE.

ogr

logical. Use the OGR query interface (via terra::query()). See details. Default: FALSE uses 'RSQLite' driver instead of 'terra'.

...

Additional arguments to terra::query() (such as start, n, vars, where, extent, filter) are passed when ogr=TRUE (or using alias gpkg_ogr_query()). Otherwise not used.

Value

a data.frame result of RSQLite::dbGetQuery() or SpatVector result from terra::query().

Details

The GeoPackage driver supports OGR attribute filters. Provide filters in the SQLite dialect, as they will be executed directly against the database. If Spatialite is used, a recent version (4.2.0) is needed and cast operators are required to transform GeoPackage geometries to Spatialite geometries. A variety of SQL functions are available, see: https://gdal.org/drivers/vector/gpkg.html#sql-functions