How to Use Custom SVG Map Symbols in Inkscape and QGIS

Using Vector Graphic Parameters to Enhance Map Symbols and Improve Workflow

Creating custom SVG map symbols requires a quick manual code adjustment after exporting your vector artwork. While Inkscape is excellent for drawing paths, it embeds presentation styles natively. To make a symbol dynamic so QGIS can directly modify things like fill color, outline color, and opacity, you must swap these static style tags with dynamic QGIS parameter functions.

Here is a step-by-step guide to building custom, data-definable map markers.


Step 1: Design the Symbol in Inkscape

I won’t go into the details on how to draw or design your SVG vector file in Inkscape. There are plenty of tutorials to be found online for that. Instead, I will offer some useful tips:

  • Keep your vector paths clean and simple to ensure smooth rendering inside QGIS.
  • Set the Document Canvas: Open Inkscape, go to File > Document Properties, and change the display units to pixels (px). Set the canvas width and height. It doesn’t need to be square (e.g., 32x32 px or 64x64 px), but it can make things easier when plotting on the map.
  • Center your drawing: Ensure the object sits directly in the center of the canvas so the anchor point aligns properly on your map.
  • Remove Extra Layers: Grouping objects is fine, but avoid excessive nested layer structures.
  • Name your Vector Objects: Use something unique and identifiable so you can find where to insert parameter code into the SVG file later.
  • Export as Plain SVG: Go to File > Save As…, type your file name, and change the file format dropdown from Inkscape SVG to Plain SVG (*.svg). This is not entirely necessary, but it removes a lot of extra Inkscape-specific metadata.
Here we have a beautiful maple leaf vector image. Note the Object Properties panel is used to provide a name for the vector object.

Step 2: Inject QGIS Parameters into the SVG Code

QGIS parses SVG nodes for specific param() attributes. It cannot read these if they are buried inside a standard style="..." string.

  1. Open your exported Plain SVG file using a plain text code editor like Notepad++, VS Code, or TextEdit.
  2. Locate the vector path element, which typically begins with <path or <polygon. If you named your objects in Inkscape, you can search for the “id= ” tag with the name of your object.
  3. Insert distinct XML attributes using the param() placeholder format. I provide a table of different options below.
  4. It’s important that the param() placeholder is inserted within the <path or <polygon tag (meaning between the < opener and /> closer symbols. See the example photo). Otherwise the the parameters won’t take effect.
  5. Save the changes and close the text editor.
Here is a section of the SVG file opened in a text editor. Green highlights show the < and /> opener and closers for the “path” tag. Yellow highlight shows the “id=” tag for the object named “maple_leaf”. Orange highlight shows the fill parameter code inserted. This will allow updating the fill color parameter in QGIS.
ParameterEffect
fill=”param(fill)”Changes the fill color of the object
stroke=”param(outline)”Changes the outline (stroke) color of the object
opacity=”param(fill-opacity)”Changes the fill opacity of the object
stroke-opacity=”param(outline-opacity)”Changes to outline (stroke) opacity of the object

Step 3: Link Your Custom Folder to QGIS

Before loading the symbol, you should tell QGIS where your custom graphics library lives. I’ve outlined this process in a previous post on how to dynamically place multiple custom symbols on a map using attribute data.

Step 4: Apply and Style Your Symbol

Now you can utilize your custom marker just like any default QGIS asset.

  1. Click the Symbology tab in the layer Properties window, or use the Layer Styling panel.
  2. Highlight the child symbol tier (usually labeled Simple Marker) and change the Symbol layer type drop-down to SVG Marker.
  3. Locate and select your custom symbol.
  4. Adjust the marker properties. Depending on the param placeholders you inserted into the SVG file, you will notice the Fill color, Stroke color, and Stroke parameters are editable.
Here we have the custom SVG marker in place marking a Canadian border crossing. Note the Fill Color drop down can now be used to change the color of the symbol. Inserting additional param placeholders in the SVG file will allow for the stroke color (or outline color) and opacity (utilizing the Stroke width parameter box) to be edited as well.

The fun part is, you can mix and match the param placeholders in the SVG file to allow adjusting the different symbol parameters. Say you want to adjust the colors of two separate objects in your symbol, well all you have to do is set the fill parameters in the SVG file to the two different QGIS color options. Just remember to name each separate object in Inkscape before saving the SVG, and insert param placeholders into the file similar to this:

  • Object #1: fill=”param(fill)”
  • Object #2: fill=”param(outline)”

Now you can change two colors on one symbol using the same process!

QGIS also allows dynamic overide of the colors with a very similar process and only a couple extra steps, but I will save that saga for another post!

Until next time, keep exploring the world around you!

Comments

Leave a Reply

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