2

I created a layer where the coordinates of each point (representing an earthquake) are imported from a CSV file. Each point also has an associated string ID. In another folder I've a database of SVG images whose filenames match the ID of each point in the CSV file.

I successfully associated and plotted each SVG image to its respective point using the "SVG Marker" symbol layer type and then using Expressions to create the automatic concatenation from the SVG database:

concat('/absolute/path/to/SVG/folder/', "name", '.svg')

The resulting image is the following: enter image description here

I exported this layer as an ESRI shapefile and saved the symbol styles in a QML file. It can be loaded flawlessly later on in any other QGIS project. But I also need to share this layer with more people.

This is the problem: Symbols are tied to the SVG database location I gave in the Expressions line, so loading the layer with these symbols will work correctly only in my computer, but not in other computers.

Is there a way to embed these symbols within the layer when it gets exported, so they don't depend on the path anymore?

I haven't found a way to do it so far.

2
  • Recent qgis version ( not sure exactly when it was added) have the option to embed svg symbol in the project, you could try that and share the project
    – J.R
    Commented Nov 23, 2021 at 22:58
  • There also is an @project_folder variable, which can be used to do relative paths. Not sure, if that's working here, though. You need to set your project folder in your project options>General
    – e-shirt
    Commented Dec 2, 2021 at 6:52

2 Answers 2

2

If you are going to share QGIS projects with others, I would recommend to store the projects in GeoPackage files (Project > Save To > Geopackage...).

Then save all your SVGs inside the same GeoPackage files.

For more info see here: Read (and write) SVG from Geopackage with QGIS, Using embedded SVG symbol in multiple layers

1

The option is not very visible, but you can embed SVG files in the project.

In the SVG Marker properties, click the small arrow next to the SVG path and select Embed File.... Select the desired file and press OK.

enter image description here

4
  • 2
    That's totally true, but unfortunately you cannot use the embedded symbol in multiple layers. You have to embed it again and again unless you store the symbol inline in a QGIS variable and reference the variable.
    – christoph
    Commented Nov 24, 2021 at 10:54
  • That was not the question. Actually, you have written and answered that question yourself pretty well :-) Commented Nov 24, 2021 at 10:57
  • Thanks! But, does this work automatically for hundreds of these SVG files that have been already loaded with Expressions (the symbol on the right of the arrow)? So far, I haven't been able to make it work. Commented Nov 29, 2021 at 21:12
  • AFAIK this doesn't work with expressions, see here. But you can upload the SVGs to a publicly accessible online platform/database and reference the URL in expressions. Takes a whole lot of time to load, sadly. Not sure, if this can be a workaround for you, depends on where you're going with your map.
    – e-shirt
    Commented Dec 2, 2021 at 6:49

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.