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

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

gpkg_ogr_query(x, query, ...)



A geopackage object


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


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.


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


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: