After not getting enough detail on that part of my problem in this post, I am now trying in a separate question.
I am unable to do data defined override with SVG markers on a line layer. I'm not sure whether it's a syntax problem or caused by something else.
I have an integer field with numbers 1-25 and want to define different centroid markers on my lines for each value with DDO. DDO is mandatory because I need to use multiple overrides to style by more than one field.
These are the variations that don't get any errors, but still don't show my chosen symbols:
case
when "Schild" = 1 then '\\srv-daten\dokument\projectfolder\Projektdaten_Erhebung\Verkehrszeichen_Piktogramme\Zeichen_237_-_Sonderweg_Radfahrer_StVO_1992.svg'
when "Schild" = 2 then '//srv-daten/dokument/projectfolder/Projektdaten_Erhebung/Verkehrszeichen_Piktogramme/Zeichen_237_-_Sonderweg_Radfahrer_StVO_1992.svg'
when "Schild" = 3 then 'O:\dokument\projectfolder\Projektdaten_Erhebung\Verkehrszeichen_Piktogramme\Zeichen_237_-_Sonderweg_Radfahrer_StVO_1992.svg'
when "Schild" = 4 then 'O:/dokument/projectfolder/Projektdaten_Erhebung/Verkehrszeichen_Piktogramme/Zeichen_237_-_Sonderweg_Radfahrer_StVO_1992.svg'
when "Schild" = 6 then '@project_folder\Projektdaten_Erhebung\Verkehrszeichen_Piktogramme\Zeichen_237_-_Sonderweg_Radfahrer_StVO_1992.svg'
when "Schild" = 7 then '@project_folder/Projektdaten_Erhebung/Verkehrszeichen_Piktogramme/Zeichen_237_-_Sonderweg_Radfahrer_StVO_1992.svg'
end
I also tried using file_path()
and file_name()
which generate errors and can not be applied.
The SVG-files are on a network drive in the project folder while QGIS is of course installed on my local drive. Could this be the problem? Or am I just using the expressions wrong?
I am using QGIS 3.20.0 on Windows 10.
Best Answer
A working Example
Let's assume there is a point layer with three point features in it, see the image below
Proceed with:
RMC > Properties > Symbology > Symbol layer type: SVG Marker
. Then go to theDynamic SVG parameters > Edit...
.Approach #1: Using the SVG-file locally stored on your machine
In the Expression String builder use the following expression:
and get the following result:
Above I am working with a folder
C://TempDaten
where all my SVG markers are stored.Approach #2: Using the SVG-file as a string
Based on the approach suggested by @christoph, then your expression will look like this:
and get the output:
Approach #3: Using the SVG-file via its URL
Your expression now is:
So, the result may look as following
A HOW TO chapter
Here I tried to sum up some basics regarding the referencing to a SVG file. (Mind that it could vary depending on the OS)
/
(single slash)//
(double slash)\
(single backslash)\\
(double backslash)@project_folder || '/yourfile.svg'
@project_folder || '//yourfile.svg'
@project_folder || '\\yourfile.svg'
What to keep in mind:
I am on Windows 10 with QGIS 3.18.1-Zürich.
References: