Creating SVG Symbols in QGIS – How to Create SVG Symbols with Modifiable Fill Color, Stroke Color, and Stroke Width

inkscapeqgissvgUbuntu

I want to create some svg symbols for Qgis using Inkscape, those symbols must have attributes as described in the question. For the last two days, I have been experimenting as instructed by Sourcepole and mimicked some symbols came bundled with qgis that have desired attributes without any success.

Finally I experimented with the simplest form of symbol: I created an svg that contains only a circle in Inkscape and tried to modify it.

The original file (circle.svg) have this line:

<path
   sodipodi:type="arc"
   style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:1.01988637;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"

I modified it into:

<path
   sodipodi:type="arc"
   style="fill:param(fill) #ffffff;fill-opacity:1;stroke:param(outline) #000000;stroke-width:param(stroke-width) 1.01988637;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"

Saved as circle_modified.svg and selected it as point symbol, but Qgis couldn't change all three parameters at the same time.

What did I do wrong or should do differently?

My system: Qgis 1.8.0 on Ubuntu 12.04 64 bit, Inkscape 0.48, Gedit 3.4.1 text editor.

Best Answer

To create SVG symbols with modifiable fill color, stroke color and stroke width in QGIS, you should replace the style attribute from the path element with these 3 attributes:

  • fill="param(fill) #FFF"
  • stroke="param(outline) #000"
  • stroke-width="param(outline-width) 1"

If you are using InkScape, after writing the new SVG file, edit the file and replace the entire line beggining with style:

style="fill:#00a000;fill-opacity:1;stroke:#000000;stroke-width:1;(...)"

with the following line:

fill="param(fill) #FFF" stroke="param(outline) #000" stroke-width="param(outline-width) 1"
Related Question