How to edit a svg symbol (colour, stroke) in QGis

If you import or create svg symbols to use in QGis you will noticed that the colour change options and outline of these symbols are disabled in QGis. In fact, these settings are hard-coded in the svg file and, if you want to set your symbol in many colours, you are forced to create as many symbols as colours you want. Here is a little tip that will save you time by not creating just only one symbol and by activating the QGis colour and contour controls for this symbol. For example, let’s take the following symbol

The colour and border modification block is inactive.The colour of the arrows is black because such is the hard definition contained in the svg file.

 We will, simply, edit the svg file to change this situation. The modification is very simple; you can use any text editor. Open the file:

After the header lines, you find the tag <path and the beginning of the definition of the symbol d=

Between both of them, you can find settings such as style = »Fill : # 000000″or others.

The trick is to replace all that is between <path and the text = by the following

 fill = “Param(fill) #FFF »Stroke= » Param(outline) # 000″ stroke-width = » Param (outline-width) 1″As we can see in the following image:  

If you use this new file for your style layer, you will see that the options that were inactive are now available:

The symbol is now white by default with black outlines but you can modify them, as well as the thickness:

Si cet article vous a intéressé et que vous pensez qu'il pourrait bénéficier à d'autres personnes, n'hésitez pas à le partager sur vos réseaux sociaux en utilisant les boutons ci-dessous. Votre partage est apprécié !

Leave a Reply

Your email address will not be published. Required fields are marked *