SVG symbols in QGIS with modifiable colors

SVG markers are a popular way to symbolise points in QGIS. Predefined markers are available in $PREFIX/share/qgis/svg and it is straightforward to add new symbols or to create own symbols with a vector graphics program (e.g. Inkscape). A disadvantage so far was the need to create different versions of an svg file to have the same symbol in several colors. A recent change in QGIS now introduces the possibility to insert parameter tags into the svg file and QGIS is going to replace them with the values for fill color, outline color and outline width.

It works with a syntax similar to the svg params working draft. Let’s say we have the following simple svg file:

<svg width="100%" height="100%">
<rect fill="#ff0000" stroke="#00ff00" stroke-width="10" width="100" height="100">

To have the possibility to change the colors of the marker, we have to add the placeholders ‘param(fill)’ for fill color, ‘param(outline)’ for outline color and ‘param(outline-width)’ for stroke width. These placeholders can optionally be followed by a default value:

<svg width="100%" height="100%">
<rect fill="param(fill) #ff0000" stroke="param(outline) #00ff00" stroke-width="param(stroke-width) 10" width="100" height="100">

Now it is possible to change fill color, outline color and stroke width using the new elements in the QGIS symbol layer dialog.


Replacing parameters and rendering svg can be expensive in terms of processing time. Therefore, an svg cache has been added which accelerates painting of svg markers considerably. For drawing on screen and with QGIS server, the svg markers are painted as rasters. For printing, a vectorized output is generated.

This work was funded by the Canton of Solothurn (Switzerland). Thank you very much!

Multiple map grids in the QGIS print composer

„Geo For All“ - neue Technologien für eine Welt im Wandel

Packaging PostGIS dev releases with Docker

FOSSGIS 2014 slides

NTv2 transformations with QGIS