QGIS – Geopackage – How create and use a “View”

Geopackage is a “Database” and it is possibile to use SQL syntax to perform “operations”. So, we can create or alter tables, add records (…) and last but not least create “views“. But… If you are able to create a “view” (for examples, using the DB Manager plugin or an external GUI), when a connection is established  between QGIS and Geopackage this “View” is “hidden” and it is impossible to use it like a layer. Never mind! Take a look at: https://issues.qgis.org/issues/18026:

“creating (only) a simple view is not enough. You need to add more information to the gpkg to make this work:
(1) add the view name to the table `gpkg_contents`
AFTER that
(2) add the geometry column to the table `gpkg_geometry_columns`
So in your case:
INSERT INTO `gpkg_contents`(`table_name`,`data_type`,`identifier`,`min_x`,`min_y`,`max_x`,`max_y`,`srs_id`)
VALUES (‘strom_zasah’,’features’,’strom_zasah’,-549173.0,-1185720.0,-548426.0,-1185130.0,5514);
INSERT INTO `gpkg_geometry_columns`(`table_name`,`column_name`,`geometry_type_name`,`srs_id`,`z`,`m`)
VALUES (‘strom_zasah’,’geom’,’Point’,5514,0,0);”

 

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.


%d bloggers like this: