8

My organisation uses mainly ArcGIS and we have a need to share data with contractors. I recently introduced QGIS (because one of our application uses WKT to import geospatial data and QGIS makes the conversion of various formats to WKT very easy) so I started to look at the geopackage format and QGIS as a data sharing solution - we want to stop using shapefiles because of the column length limitations.

Using QGIS I can create a geopackage with a single layer using 'save as', read and edit the layer using QGIS, read it using ArcGIS however, if I try to add layers to the geopackage using DB Manager (as per How to add another layer to GeoPackage in QGIS?) I get an 'error 11 connection to database failed'. I definitely have a connection to the geopackage in DB Manager as I can preview the existing layer and run a query (i.e. select * from [layer]).

This seems to be a bug (https://hub.qgis.org/issues/14981) that is not scheduled to be fixed so I'm wondering if there are any other tools or plug-ins available so that we can add layers to a geopackage using QGIS?

I am using Windows 10, QGIS 2.14.9 and ArcGIS 10.4.

Note: While I can add a layer to the geopackage using OGR2OGR, I cannot get 'buy-in' from our contractors, who are field specialists not IT professionals, to use command line tools instead of a GIS.

Note 2: I have discounted using spatialite for now because QGIS does not handle spatialite data created with ArcGIS. (DB Manager results in an error: dbname='H:/Temp/SQLiteTesting/BaseData/ArcSpatialite/Aspatialite.sqlite' table="arccatTrees" sql= is an invalid layer - not loaded)

  • It would be nice to see such incompatible spatialite db and investigate it a bit. – user30184 Jan 11 '17 at 5:47
12

My advice is to upgrade to >=2.18.1. Version 2.18.1 introduced a feature where right clicking a layer and selecting save as, then choosing an existing gpkg file, now gives you the choice of either overwriting the whole file or instead appending the layer as a new layer within the geopackage. [1] (ie don't use the DB Manager plugin, just use the built in 'save as' layer function)

[1] See https://github.com/qgis/QGIS/commit/85fbc4a7d902c12794fbbfeec5ce43d8a2c0887e

  • 1
    Thanks ndawson. I did some cusory testing with 2.18.2 and the save as functionality worked nicely for me. I noticed that DB Manager has changed and has seperated spatialite and geopackage in the UI. I again tried the import using and DB Manager but it still failed. 'Save as' is the way to go! :-) – Colin Jan 12 '17 at 2:47
  • but what about creating a new layer? when i want to draw points for example and want to add it to an existing geopackage I can´t because no matter how I call the layer, this functionality tries to overwrite the entire database – hilpers Feb 2 '17 at 16:52
  • 1
    Also, an option to directly save outputs of geoalgorithms to geopackage would be gorgeous – hilpers Feb 3 '17 at 8:14
  • I am able to add for example new polygon features to existing GPG with polygon data. But it is possible to add various layers (point, polygon etc.) together in one GeoPackage? I was not able to achieve this. (have QGIS 2.18.13) – Juhele Mar 7 '18 at 15:28
  • sorry, my fault. I forgot to enter unique name for each layer in GPG so QGIS used GPG filename for layer name and thus each new layer tried to append to the existing one instead of adding. – Juhele Mar 14 '18 at 12:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.