I have a gpkg of several layers. How can I rename them in the gpkg as well as in the QGIS layers list?
Basically, I have layer
foo in my QGIS project, whose source is
filename.gpkg|layername=foo. I now want to call it
It's easy (rightclick, rename) to change
bar in the QGIS project layer list. But it's still called
foo inside the gpkg. I can't rename it inside the gpkg from the GeoPackage connection inside the QGIS browser: it lets me rightclick and choose rename, but OK is greyed out (presumably since it's in use).
As a workaround, I can rename it
bar in the QGIS project layer list, export it from the QGIS project layer to a temporary gpkg (where it becomes named
foo is forgotten), import it from there as a duplicate to the right gpkg, use the
changeDataSource plugin to point the project layer to the new name, and then clean up by deleting the old
foo in the gpkg. And eventually vacuum the db.
But that's a hassle given I've set up a naming convention to use across projects, and now need to rename 20+ layers across several gpkg to reflect it (and so I and others can re-use those gpkgs in other projects).