I have a bunch of variables to map with same geometry (Regional Boundaries), and wanted to create separate layers with differing attributes within a single geopackage file for ease of file management. However, when I save the duplicate layer into a geopackage I get an error "Export to vector file failed. Error: Cannot overwrite a OGR layer in place". This seems to be expected behavior according to this bug report. Is there a way around this? Creating separate gpkg files for each layer seems to be unnecessary/superfluous. Or am I misunderstanding the entire concept of geopackage as a an analogue to Esri's geodatabase?
-
Do your layers have different names?– user30184Commented Jun 1, 2018 at 21:28
-
yes. Names are different. Otherwise they are identical (same geometry/attributes).– RuslanCommented Jun 1, 2018 at 21:29
-
GeoPackage does not set such limitations. Perhaps QGIS does. With ogr2ogr it is for sure possible.– user30184Commented Jun 1, 2018 at 21:38
-
the bug report doesn't say it's expected, just that it looks that way to the program. reopen the bug report and make it clearer why this is an issue– Ian TurtonCommented Jun 2, 2018 at 10:53
-
1According to this post, the problem has been solved with QGIS 3: gis.stackexchange.com/questions/281201/…– Stu SmithCommented Jun 3, 2018 at 5:33
2 Answers
Thanks to @user30184 for an answer, that prompted me to discover a workflow that works even better for me. Since my original question was nested in need to create multiple thematic layers (primarily based on excel sheets + attribute joins), I discovered that doing a join on a layer and then saving it into the geopackage does not prompt any errors. So instead of duplicating layers and then attaching attributes through table joins, it is easier to do joins first and save files after (as output from the join), then there are no errors and duplicate geometries are saved into a single GPKG.
Instead of using the Save as... option use the DB Manager tool. In the example below I had opened layer "test_2" from GeoPackage "test" and I imported it back to the same GeoPackage with a new name. I tested that is is possible to import duplicated layers in the same manner.