Table Of Contents

Previous topic

Chart Plugin

Next topic

Shapefile Renderer

This Page

SVG Plugin

The gt-svg plugin uses the Batik library to support the use of SVG graphics.




The following example is taken from test cases:

Here is the example fillHouse.sld:

<?xml version="1.0" encoding="UTF-8"?>
<StyledLayerDescriptor version="1.0.0" xmlns=""
  xmlns:ogc="" xmlns:xlink="" xmlns:xsi=""

                    <OnlineResource xlink:type="simple" xlink:href="house.svg" />

Parameter extension

The plug-in can handle a basic support for parametric styling based on the SVG Parameters 1.0 specification The support is limited to attribute values, as the underlying library (Batik) cannot perform parameter expansion on its own.

This is good enough to work again QGis own SVG library, here is a simple excerpt from the square symbol, notice the param(paramName) calls making the style parametric:

<rect x="37.064" y="37.065" fill="param(fill)" fill-opacity="param(fill-opacity)" stroke="param(outline)"
      stroke-opacity="param(outline-opacity)" stroke-width="param(outline-width)" width="505.871" height="505.871"/>

The parameter values can be specified as URL parameters, for example:

<OnlineResource xlink:type="simple" xlink:href="square.svg?fill=xFF0000&fill-opacity=0.5" />

While any type of parameter can be handled, it’s best to follow a naming convention, in particular:

  • Any parameter representing a width must contain “width” in its name
  • Any parameter representing a opacity must contain either “opacity” or “alpha” in its name
  • Any other parameter should be a color

This is because BATIK will log on the standard error any parsing issue, in particular, any non replaced parameter. The above conventions give the parameter replacement engine an opportunity to set default values for missing parameters (in particular, 0 for width, 1 for opacity/alpha, x000000 for colors).