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.

PolyGeo
  • 65,136
  • 29
  • 109
  • 338
  • 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 Nov 23 '21 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 Dec 02 '21 at 06:52

2 Answers2

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

christoph
  • 5,605
  • 1
  • 20
  • 34
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

Alexandre Neto
  • 14,212
  • 2
  • 58
  • 85
  • 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 Nov 24 '21 at 10:54
  • That was not the question. Actually, you have written and answered that question yourself pretty well :-) – Alexandre Neto Nov 24 '21 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. – Carlos Herrera Nov 29 '21 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 Dec 02 '21 at 06:49