GeoPackage

Spectrum Spatial supports the GeoPackage data provider for Windows and Linux. GeoPackage is a spatial extension to the SQLite database technology. The GeoPackage standard, adopted by OGC, allows for multiple tables, their relationships, and relevant metadata to be self-contained within a single file. It is useful for large datasets and for working around character set and data size limitations in MapInfo Pro.

Spectrum Spatial treats GeoPackage as a read-write data source.

Compliance to the GeoPackage Specification

Spectrum Spatial's support for GeoPackage was designed to be as compliant as possible with the OGC specification. However, other implementations that support it (either for reading, writing, or creating) may not be entirely compliant.

Spectrum Spatial considers a GeoPackage table compliant if it:

  • includes a gpkg_spatial_ref_sys table as specified in Requirement 10 of the OGC specification
  • includes a gpkg_contents table as specified in Requirement 13
  • contains tables or updatable views that contain vector features, then those feature tables or views have a column with column type INTEGER with PRIMARY KEY AUTOINCREMENT as specified in Requirement 29.
  • implements spatial indexes on feature table geometry columns as specified in Requirements 70, 71, and 72
    Note: An RTree index, although not mandatory, is recommended to prevent performance issues.

Accessing Data in GeoPackage

A GeoPackage file has an extension of .gpkg and is essentially a database that contains tables. To access GeoPackage data with Spectrum Spatial, create a file-system named connection using Spectrum Spatial Manager. A connection to a GeoPackage file is a path, similar to TAB and shapefiles. Once the connection is created, you can create named tables that use it. You use GeoPackage named tables as you would any other data provider named tables. A GeoPackage table should have a spatial index to work with Spectrum Spatial. Sample data for GeoPackage is available in the /Samples/NamedTables folder in the repository (WorldGeoPackageTable). The older version of the Map Uploader (for MapInfo Pro versions prior to 16.0), does not support GeoPackage. Both read and write permissions are required on the parent folder of a GeoPackage file in order to open the GeoPackage database.

Supported Data Types

The GeoPackage data source provider follows the same rules as generic JDBC when mapping a non-spatial JDBC type to Spectrum Spatial’s type system. The gpkg_geometry_columns table is consulted for the name of the spatial column and the coordinate system.

The geometry and geography data types are the spatial data equivalents to Spectrum Spatial's supported data types: Point, LineString, Polygon, MultiPoint, MultiLineString, MultiPolygon, and GeometryCollection.

Primary Key

The GeoPackage specification identifies the column in the table that serves as the primary key. This column will be marked as read-only since it is an auto-increment column.

Insert, Update, and Delete Support

Insert, update and delete operations are supported on a GeoPackage data source provider. The Write Ahead Logging (WAL) journal mode of SQLite is used to allow concurrent read and write for GeoPackage, with these limitations:

  • All processes using a database must be on the same host computer; WAL does not work over a network file system.
  • It is not possible to open read-only WAL databases. The opening process must have write privileges for the "-shm" wal-index shared memory file associated with the database (if that file exists), or else write access on the directory containing the database file if the "-shm" file does not exist.

For more details about WAL, including its advantages and limitations, see http://www.sqlite.org/wal.html.

MI SQL Optimizations

GeoPackage supports the same non-spatial functions and operators as the Generic JDBC data source provider along with the spatial operator EnvelopesIntersect.

For more information see the appendix Delegation to Data Source Providers.

Volatility

For GeoPackage, volatility is any change to the table's schema, such as adding or dropping a column or changing an index on a column. If it has changed, Spectrum Spatial will flush the metadata about the table from the cache and reload it before proceeding with the data access operation. See Data Source Volatility for more information.

GeoPackage and MAPINFO_MAPCATALOG

The GeoPackage data provider in Spectrum Spatial does not use a MAPINFO_MAPCATALOG. This has several implications:
  • Geometries read from a GeoPackage table have no style and will be rendered as a black and white layer in a map. If you need styles, use an override theme.
  • XY tables cannot be created from a GeoPackage table. To create an XY table from a table in a SQLite database, create a generic JDBC-based named table. For example, create a connection in Spectrum Spatial Manager with a string such as jdbc:sqlite:c:\data\sample.gpkg following the instructions in Creating a Connection. Then create an XY table following the instructions in Creating an XY Table.

Coordinate System Support

GeoPackage supports a Cartesian spatial reference system (SRS) when the SRID is -1 and a geographic SRS when the SRID is 0. If a GeoPackage table has an SRID of -1, use column hints to define a Cartesian SRS in the named table. If the SRID is 0, use column hints to define a geographic SRS. If these column hints are not set or are set incorrectly, the system will throw an exception. These column hints must be added manually to a named table definition using WebDAV or a text editor to add a <DBDataSourceMetadata> attribute to the XML file:

For a Cartesian SRS:

<DBDataSourceMetadata>
  <FeatureGeometryAttribute srsName="epsg:3857">geom</FeatureGeometryAttribute>
</DBDataSourceMetadata>
For a geographic SRS:
<DBDataSourceMetadata>
  <FeatureGeometryAttribute srsName="epsg:4326">geom</FeatureGeometryAttribute>
</DBDataSourceMetadata