Deltares / Ribasim

Water resources modeling
https://deltares.github.io/Ribasim/
MIT License
36 stars 5 forks source link

write QGIS style to GeoPackage #610

Open visr opened 9 months ago

visr commented 9 months ago

Currently the Ribasim QGIS plugin applies styling to the layers on loading a model.

It would be nice if we could get the styling information out of the plugin and into the GeoPackage itself. That way the plugin does not need to be used for a good looking label. QGIS supports saving styling information to the GeoPackage. I think this is QGIS specific, and not sure how/if the GeoPackage spec says anything about it (it seems not).

It's worth looking into if we can get ribasim-python to write this information to the GeoPackage.

visr commented 9 months ago

In QGIS layer properties under "Style" you can save styles as QGIS QML Style File, SLD Style File, or In Database (GeoPackage). Choosing the latter adds a layer_styles table with one row per layer, and a styleQML and styleSLD field with XML encodings of the styles.

image

We can save these few hundred lines (for Node) of style encodings in the code and just add them (and update them visually in QGIS), or use a tool like pySLD to create them from code.

Edit: this works: https://github.com/Deltares/Ribasim-NL/issues/4#issuecomment-1730983175

deltamarnix commented 7 months ago

I would prefer not to remove the code, as you never know if you receive old files that don't contain the styling. And at the same time, if you want to update your styling with a new release of your plugin, wouldn't you want your geo files to be updated automatically as well? If you save the information in the package, they are stuck there.

visr commented 3 months ago

Here a QML style for 'Basin / area' styling by @DanielTollenaar, with graduated semi transparent blues.

basin_area.qml.txt

visr commented 3 months ago

If you save the information in the package, they are stuck there.

True, but we currently only support using the set of components together for the same Ribasim release. We may support upgrading models in the future, and if we do this we could decide to upgrade the style as well.