QGIS GeoPackage – Layers Saved in Wrong Order Issue

geopackageqgis

I would like to save my file as the .geopackage file. Unfortunately, I've noticed that the order of the layers is not correct. It doesn't correspond to the order in the "Layers" panel.

I saw, that the DB manager is required for this purpose:

https://www.reddit.com/r/QGIS/comments/l5r2pa/grouping_layers_inside_geopackage/

or some coding is required:

Reordering layers in GeoPackage and changing the default naming in QGIS?

enter image description here

but is there some other option, which would assure me, that the layers in .geopackage file are in the correct order? It applies also to the situation after saving. When I attended to load the .gpkg file, this order is also different.
How can I solve this problem?

Best Answer

Because (in earlier releases of QGIS) the layers in your project are being reordered alphabetically on save to geopackage, there is no built in way to preserve the layer order and override this alphabetization in this case.

However, one workaround is to simply add an alphabetical or numerical prefix at the front of your layer names that reflects the order you would like them to be saved in (i.e., A-, B-, C-, etc... or 1-, 2-, 3-, etc...) and let the new names dictate the way they will be reordered in the geopackage.

Related Question