# GeoPackage

This driver implements support for access to spatial tables in the OGC GeoPackage format standard. The GeoPackage standard uses a SQLite database file as a generic container, and the standard defines:

- Expected metadata tables (`gpkg_contents`, `gpkg_spatial_ref_sys`, `gpkg_geometry_columns`)
- Binary format encoding for geometries in spatial tables (basically a GPKG standard header object followed by ISO standard well-known binary (WKB))
- Naming and conventions for extensions (extended feature types) and indexes (how to use SQLite r-tree in an interoperable manner)

This driver reads and writes SQLite files from the file system, so it must be run by a user with read/write access to the files it is working with.

## Limitations

- GeoPackage only supports one geometry column per table.
- This driver does not currently implement the GeoPackage index extension.
- GeoPackage does not currently support non-spatial tables.

## SQL

The driver supports OGR attribute filters, and users are expected to provide filters in the SQLite dialect, as they will be executed directly against the database.

## Creation Issues

When creating a new GeoPackage file, the driver will attempt to force the database into a UTF-8 mode for text handling, satisfying the OGR strict UTF-8 capability. For pre-existing files, the driver will work with whatever it's given.

### Dataset Creation Options

None

### Layer Creation Options

- GEOMETRY_COLUMN: Column to use for the geometry column.
- FID: Column name to use for the OGR FID (primary key in the SQLite database).
- OVERWRITE: If set to "YES" will delete any existing layers that have the same name as the layer being created.
- SPATIAL_INDEX: [NOT IMPLEMENTED] If set to "YES" will create a spatial index for this layer.

### Examples

- Simple translation of a single shapefile into GeoPackage. The table 'abc' will be created with the features from abc.shp and attributes from abc.dbf. The file `filename.gpkg` must not already exist, as it will be created.

      % ogr2ogr -f GPKG filename.gpkg abc.shp

- Translation of a directory of shapefiles into a GeoSpackage. Each file will end up as a new table within the GPKG file. The file `filename.gpkg` must not already exist, as it will be created.

      % ogr2ogr -f GPKG filename.gpkg ./path/to/dir

- Translation of a PostGIS database into a GeoPackage. Each table in the database will end up as a table in the GPKG file. The file `filename.gpkg` must not already exist, as it will be created.

      % ogr2ogr -f GPKG filename.gpkg PG:'dbname=mydatabase host=localhost'

### FAQs

- ...
  ...

### See Also

- SQLite