17

I am just playing with the GeoPackage format in QGIS. In QGIS it works nice with the style saved from QGIS but if I load it for example in SAGA the style is not applied.

Is there any way to include at least some basic style (for example point colors for value ranges or classes) so it could be used by different applications? Or is the included style always "application-specific"?

5
  • You could add columns to the attribute table for color, symbol shape, etc.
    – csk
    Commented Mar 6, 2018 at 17:16
  • but the user has to built a new style from them manually - am I right?
    – Juhele
    Commented Mar 12, 2018 at 10:27
  • It depends on the program. In QGIS, if you use the same column names in multiple layers, you can create one style and load it for each layer. So it saves you a few steps, but you still have to create the style in the same program. I don't use SAGA, so I'm not sure how it would work with that program.
    – csk
    Commented Mar 12, 2018 at 16:56
  • I know that I can easily copy style in QGIS and easily use copy of the same qml file for several shp layers to load them with the style in QGIS. I also know that I can save the QGIS style to Geopackage to be applied same way as the qml with shp. However I was curious whether the Geopackage standard also contains some universal style definitions which is compatible in more apps supporting Geopackage format.
    – Juhele
    Commented Mar 13, 2018 at 8:33
  • 2
    Is it possible to do this by python code ?
    – Feneck91
    Commented Jun 24, 2019 at 14:50

3 Answers 3

17

QGIS support its own format QML and SLD. When you use GeoPackage (or PostGIS) you can save the style on the GeoPackage and distribute both the data and the style. On the layer properties, the Style button has an Save Style option and you can choose Save in database (GeoPackage).

enter image description here

The style is saved on a table inside your GeoPackage called layer_styles. The style is saved as QML (on styleQML column) and also saved as SLD (on styleSLD column).

enter image description here

Other softwares, like SAGA, GeoTools, etc, could support this same approach, reading the layer_styles table, if present, and use the SLD style stored in the GeoPackage.

Try to convince SAGA developers to support SLD. If SAGA gets SLD support, we could use and share the SLD style saved on the GeoPackage.

4
  • Can you post a small bit about how you save the style to geopackage? Commented Mar 17, 2018 at 18:25
  • I've added more details about saving the style in the database to the answer.
    – jgrocha
    Commented Mar 18, 2018 at 21:22
  • OK, thanks for the information about saving SLD in the GPG - I thought it just adds the QML which is QGIS-only. I will ask my friend to load my files in other programs to see which other are able to load the SLD style.
    – Juhele
    Commented Mar 18, 2018 at 23:27
  • If I could now find a way how to use the SLD in layer_styles in ArcMap, I would be all set to work in a mixed environment. Apparently, an unsolved problem for years now?
    – aae
    Commented Jul 14, 2020 at 14:43
1

Note that the GUI has changed since jgrocha's answer. I thought there must have been something wrong with my QGIS or the way I was loading gpkg layers, since I couldn't see the option to "Save in Database".

The option is now available in a drop-down after you select "Save current style" or "Save multiple styles": enter image description here enter image description here

It saves styles to the gpkg in both QML and SLD format.

0

On the layer properties, the Style button has an Save Style option and you can choose Save in database (GeoPackage)

This works only for layers already in a geopackage though. You cannot load a shapefile, style it, and use a geopackage to store the styling. So you cannot, for instance, use a geopackage to store and circulate a collection of styles.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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