15

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
    Mar 6, 2018 at 17:16
  • but the user has to built a new style from them manually - am I right?
    – Juhele
    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
    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
    Mar 13, 2018 at 8:33
  • 1
    Is it possible to do this by python code ?
    – Feneck91
    Jun 24, 2019 at 14:50

2 Answers 2

16

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? Mar 17, 2018 at 18:25
  • I've added more details about saving the style in the database to the answer.
    – jgrocha
    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
    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
    Jul 14, 2020 at 14:43
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, privacy policy and cookie policy

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