4

I have a point table which contains a column of Animals names. and an SVG file folder of these animals. The svg files have the same names as the animals.

I would like to know if in the GIS symbology of QGIS there is an automatic way to create SVG links between my table and my folder where the SVG files are ?

I mean for each point it reads in the table the name of the animal (for example fox) and it creates the link, loads and displays the fox.svg symbols found in my file.


I used one of the answers but when I have the empty boxes (NULL) it displays question marks "?"

Here is a screenshot:

enter image description here

2 Answers 2

5
  1. In the symbology panel of your point layer select the "Simple Marker"
  2. Change the Symbol layer type to "SVG marker"
  3. Go almost to the bottom of the panel and locate the SVG path bar and click on the data defined override icon on the right and select Edit, this will open the expression editor where you will be able to input an expression that return the path for your SVG based on animal name, it will probably look like this 'C:/SVG_Folder/' || "Animal_Field_Name" || '.svg' (just replace the C:/SVG_Folder/ by the actual path to the SVG folder and Animal_Field_Name by the name of the field with the animal name)

enter image description here

2
  • I want to add a condition, if the field is null, empty or does not correspond to an SVG file, it does nothing, but loads the other fields. Because today when in there is an empty or null field or aui does not correspond to an SVG file in does not load the other fields Jun 18, 2023 at 10:18
  • Thank you for your answer but when I have the empty boxes (NULL) it displays question marks "?" how to cure it? Here is a screenshot on the main post Jun 19, 2023 at 9:13
5

If you have a field called animal with entries like dog, fish etc., set marker symbol to SVG marker and use data driven override for the path with this expression, where [your path] is the path to the directory where you have stored SVG files called dog.svg, fish.svg:

'[your path]'  || "animal"  || '.svg'

Like this, the correct image will automatically show up and is dynamically changed when you change the animal's name or add a new feature.

enter image description here


Edit:

When you have some fields that is NULL, empty or does not correspond to an SVG file, a question mark will be shown. To hide this, go to Enable symbol layer > Data driven override ​(ɛ icon) and paste this expression that returns true if the field svg in not NULL and if an svg file with this name exists in the folder:

svg is not NULL and file_exists('[your path]' || svg || '.svg')

Only for the features highlighted in yellow, the corresponding SVG icon shows up on the map: enter image description here

7
  • Thank you for all Jun 16, 2023 at 15:10
  • 1
    You're welcome. As a new user, please be adviced that this site tries to avoid "thank you" messages. Instead, it encourages you to accept an answer the solved your probel and/or upvote it if it was helpful: click the checkmark right to the answer to accept it - see: gis.stackexchange.com/help/someone-answers Just click the checkmark, see here: meta.stackexchange.com/questions/5234/…
    – Babel
    Jun 16, 2023 at 15:26
  • I want to add a condition, if the field is null, empty or does not correspond to an SVG file, it does nothing, but loads the other fields. Because today when in there is an empty or null field or aui does not correspond to an SVG file in does not load the other fields Jun 18, 2023 at 10:19
  • Not clear to me what you mean with that. Can you provide screenshot + sample data? Maybe worth posting as another question.
    – Babel
    Jun 18, 2023 at 10:20
  • Thank you for your answer but when I have the empty boxes (NULL) it displays question marks "?" how to cure it? Here is a screenshot on the main post Jun 19, 2023 at 9:12

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.