11

I am constructing a GeoPackage from vector layers that have values for a number of years, each year is an attribute (1965, 1995, 2025, 2055, 2085). I have styled the layers and added the styles to the GeoPackage. In the layer_styles file, each of my files has many styles attributed to each layer (Figure 1).

Figure 1: Layer styling has been saved to the gpkg for each attribute of interest

When I load the GeoPackage, however, only the default style loads and other styles need to be loaded from the styles interface rather than being listed along with the default style as previously (Figure 2).

Is there a way to import the GeoPackage with all styles being active and selectable from the right-click menu or will I have to load them each time from the GeoPackage for each layer?

As a follow-up (if this is not possible), what is the purpose of the f_table_name attribute in layer_styles if not to facilitate loading?

Maybe this is a bug?

Figure 2: Styles do not appear after reload, but need to be loaded in manually from the geopackage

Things I have checked/tried:

  • The styles are in fact in the GeoPackage
  • The layer does have its name listed in f_table_name for multiple styles
  • I checked for guides, but all of the ones I found only mention the default layer style, which is not ideal if I want to have many styles for the same layer. I figure there must be a reason that you are able to save multiple styles...

Alternatively, is there a better practice method for this?

I want to avoid having to save multiple instances of the same layer within the GeoPackage just for styling.

1
  • If you have the same style for each year then there is sevral workaround : Create one style rule based to merge your 5 styles in one style with the 5 case with 7 rules for each. You could then select year you want. Other solution create an expression variable in the project properties. Then set the classification column to use this value and you could change in the project properties each time. Apr 30 at 11:54
1

I played around with this a little and came up with a sort-of solution / work around (QGIS 3.10)

  • I created different styles for a single layer and listed them in the Layer Styling Panel. This allowed me to skip between styles simply by clicking on them.
  • I then went to the Layers panel, right-clicked on the layer and exported "Save as layer definition file".
  • Restarting QGIS I then loaded the Layer definition file rather than the layer from the geopackage. This had all the styles in the context menu and Layer Styling Panel.

Not sure if this is what you wanted, but maybe it helps.

Also, the qlr file is in xml format. So you can copy it and edit the content to reflect the year you are working with.

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.