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"?

csk
  • 24,827
  • 3
  • 32
  • 70
Juhele
  • 1,738
  • 2
  • 19
  • 31
  • You could add columns to the attribute table for color, symbol shape, etc. – csk Mar 06 '18 at 17:16
  • but the user has to built a new style from them manually - am I right? – Juhele Mar 12 '18 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 '18 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 '18 at 08:33
  • 2
    Is it possible to do this by python code ? – Feneck91 Jun 24 '19 at 14:50

3 Answers3

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.

jgrocha
  • 5,345
  • 25
  • 43
  • Can you post a small bit about how you save the style to geopackage? – DPSSpatial_BoycottingGISSE Mar 17 '18 at 18:25
  • I've added more details about saving the style in the database to the answer. – jgrocha Mar 18 '18 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 '18 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 '20 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.

Vince
  • 20,017
  • 15
  • 45
  • 64
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.

jfmoyen
  • 454
  • 3
  • 9