GeoPackage object represents an open connection to a single GeoPackage (.gpkg) SQLite database. You never construct one directly — obtain an instance from GeoPackageManager.open() or GeoPackageManager.create().
Table management
getFeatureTables()
Returns the names of all feature (vector) tables registered in the GeoPackage.getTileTables()
Returns the names of all tile (raster) tables registered in the GeoPackage.getAttributesTables()
Returns the names of all attributes tables registered in the GeoPackage.getTables()
Returns the names of all content tables, optionally filtered by data type.Optional data type filter. Omit to return all tables regardless of type.
hasFeatureTable()
Returnstrue if a feature table with the given name exists.
The name of the feature table to check.
hasTileTable()
Returnstrue if a tile table with the given name exists.
The name of the tile table to check.
getInfoForTable()
Returns a plain object with summary information about a feature or tile table — row count, geometry column details (features), zoom range (tiles), contents metadata, SRS info, and a column map.A DAO instance obtained from
getTileDao() or getFeatureDao().Feature access
getFeatureDao()
Returns aFeatureDao for the named feature table. Use the DAO to iterate rows, query by geometry, add or update features, and more.
Name of the feature table.
Data-access object for the feature table.
GeoPackageException— no feature table with that name exists, orGeometryColumnscould not be retrieved.
queryForGeoJSONFeatures()
Queries a feature table and returns results as GeoJSON features. Optionally filters by bounding box. Geometry types that cannot be converted to GeoJSON are silently omitted.Name of the feature table to query.
Optional spatial filter. Must be in the same projection as the feature table. Omit to return all features.
An iterable result set whose items are GeoJSON
Feature objects.Tile access
getTileDao()
Returns aTileDao for the named tile table.
Name of the tile table.
Data-access object for the tile table.
GeoPackageException— no tile table with that name exists, orTileMatrixSetcould not be retrieved.
xyzTile()
Retrieves a single tile rendered at the requested pixel dimensions using the standard XYZ (slippy-map) tile coordinate scheme.Name of the tile table.
Tile column index.
Tile row index.
Zoom level.
Output tile width in pixels. Defaults to
256.Output tile height in pixels. Defaults to
256.Resolves with a
GeoPackageTile containing the rendered image data, or null if no tile exists at those coordinates.Attributes access
getAttributesDao()
Returns anAttributesDao for the named attributes table.
Name of the attributes table.
Data-access object for the attributes table.
GeoPackageException— no contents entry exists for the given table name.
Table creation
createFeatureTableWithMetadata()
Creates a new feature table together with all required GeoPackage metadata rows (contents, geometry columns, SRS).Describes the table name, geometry column, additional columns, SRS, and bounding box. Build one with
FeatureTableMetadata.create(geometryColumns, columns, dataType, boundingBox).The created
FeatureTable object.Use
createFeatureTable(table: FeatureTable) only if you want to create the SQLite table structure without the accompanying GeoPackage metadata rows. Prefer createFeatureTableWithMetadata() for most use cases.createTileTableWithMetadata()
Creates a tile table from aTileTableMetadata descriptor. This is the recommended approach.
Describes the table name, bounding boxes, and SRS IDs. Build with
TileTableMetadata.create(tableName, contentsBB, contentsSrsId, tileMatrixSetBB, tileMatrixSetSrsId).The created
TileTable object.createTileTableWithTableName()
Creates a tile table and its associated metadata (contents row, tile matrix set row, tile matrix and tile matrix set tables) from explicit parameters.Name for the new tile table.
Informational bounding box stored in the
gpkg_contents row.SRS ID for the contents bounding box (e.g.
4326). Must be defined in gpkg_spatial_ref_sys.Precise bounding box used to calculate tile row/column coordinates.
SRS ID for the tile matrix set (e.g.
3857). Must be defined in gpkg_spatial_ref_sys.The created
TileMatrixSet object.GeoPackageException— either SRS ID is not defined ingpkg_spatial_ref_sys.
createAttributesTableWithMetadata()
Creates an attributes table and itsgpkg_contents metadata row.
Describes the table name and columns. Build with
AttributesTableMetadata.create(tableName, columns).The created
AttributesTable object.Geometry operations
getBoundingBox()
Returns the bounding box for the given table by combining the contents metadata with the actual indexed feature extents (when available).Table name.
Target projection for the returned bounding box. Defaults to the table’s own projection.
When
true, performs a full row scan to determine the bounds of un-indexed feature tables. Defaults to false.Lifecycle
close()
Closes the underlying SQLite connection. Always call this when you are finished with theGeoPackage instance.
export()
Exports the in-memory or on-disk database as aUint8Array. Useful in the browser when you need to offer the file for download, or in Node.js when building a GeoPackage in memory before writing it.
Raw bytes of the
.gpkg file.getName()
Returns the name that was assigned to this GeoPackage when it was opened or created.getPath()
Returns the file system path of the GeoPackage, orundefined for in-memory instances.