3

There is the possibility to save the style of a layer in a geopackage:

Layer.saveStyleToDatabase

This style can be read by QGIS without additional code. But is there a way for QGIS to read SVG symbols from a gpkg?

I could write the SVG by code, but reading should be done without additional code.

7
  • Do you know changelog.qgis.org/en/qgis/version/3.4-LTR/… ?
    – etrimaille
    Mar 19 '20 at 8:52
  • 1
    Which version QGIS are you using? Mar 19 '20 at 9:03
  • @etrimaille: I didn't know it yet. Would be a partial solution, but one would have to deliver an additional (proprietary) file for the GeoPackage.
    – Mike
    Mar 19 '20 at 9:18
  • @ MortenSickel: The version is not so important. I am looking for a way to exchange data with others with little effort
    – Mike
    Mar 19 '20 at 9:20
  • 1
    The version is always important. I see many people working with QGIS 2 (not even 2.18), QGIS 3.4.0... nowadays! I'm giving you an answer using QGIS 3.4, maybe you are not using it? How can I guess?And in your question, you are mentioning only SVG, not additional proprietary data.
    – etrimaille
    Mar 19 '20 at 11:14
5

I was very interested by myself, to find out how we can package a QGIS project with all external dependencies inside a GeoPackage database. With the help of the "indispensible" expression editor, it's possible to reference SVGs/images stored in a BLOB column and base64 encode on-the-fly.

  1. Create a GPKG layer (i.e. "svg") with 2 columns (name:text,image:binary[blob])

enter image description here

  1. Store your SVG images in the layer "svg" (click on the "..." button to embed the SVG):

enter image description here

  1. Reference the SVG symbols in your vector layer (i.e. table "locations", column "type")

enter image description here

  1. Use SVG Marker styling with the following expression to display your SVG symbols

'base64:'|| to_base64(attribute(get_feature( 'svg','name',"type"),'image'))

enter image description here

  1. Praise the Qt developer, who has added support for inline SVGs and inline images!

enter image description here

1

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.