alexandervlpl edited this page May 5, 2018 · 25 revisions
Clone this wiki locally

Symbolizer that specifies rendering of a png, tiff, or svg graphic symbol and label text at a point.

Effectively, this is a (working) combination of TextSymbolizer and PointSymbolizer. If you try to use a TextSymbolizer and a PointSymbolizer separated you will often see points without texts and/or texts without points.

Configuration Options

Supports all options of TextSymbolizer with additional options:

parameter value default
base Base symbol template (See below)
file The file to use for the shield background
opacity opacity of the image used for the shield 1
text-opacity opacity of the text placed on top of the shield 1
unlock-image If true the shield image doesn't move "false"
shield-dx offset the shield image and text horizontally 0
shield-dy offset the shield image and text vertically 0
transform Transform image


Add <FileSource name="foo">/home/bar/baz/</FileSource> to the beginning of your stylesheet and then use <ShieldSymbolizer base="foo" name="bridge" /> to refer to /home/bar/baz/bridge.

dx, dy

To draw labeled points configure placement="point" (which is the default) and set dx/dy to move the text.

dx, dy from TextSymbolizer moves only the text, and not the shield. This behavior will be changed in a future release of mapnik. (See below).

New interface in HarfBuzz branch

parameter value default
shield-dx, shield-dy Move shield only. 0
dx, dy With unlock_image = true: move text only. 0
With unlock_image = false: move text and shield 0
unlock_image True: Shield base point is always the input line/point (usecase: labeling bus stations). 0
False: Shield base point is the center of the text (i.e. depends on dx,dy,vertical-alignment, horizontal-alignment) (usecase: highway shields)


placement="line" only means placement along a line for ShieldSymbolizer, whereas for TextSymbolizer it rotates the text too. Add the spacing parameter to get the ShieldSymbolizer to repeat along the line, otherwise placement="line" and placement="point" will look the same.


Setting up a sample shield symbolizer, from the Cascade Users of OpenSource GeoSpatial (CUGOS) list:


        face-name="DejaVu Sans Bold" size="6" fill="#000000"
        file="images/shield.svg" spacing="100" transform="scale(2.0,2.0)" 

Python (Mapnik 2)

    shield = ShieldSymbolizer(Expression('[NAME]'),'DejaVu Sans Bold',6,Color('#000000'),PathExpression('images/ushighway_shield_20.png'))
    shield.min_distance = 50
    shield.label_spacing = 100
    shield.displacement = (dx,dy)

Python (Mapnik 3)

No support.


    rule_type rule;
    /* Parameters:
          face name
          image type
    shield_symbolizer ss("[NAME]", "DejaVu Sans Bold", 6, color(0, 0, 0), "/path/to/icon.png", "png", 20, 20);
    ss.set_label_placement(mapnik::LINE_PLACEMENT); // Place label along the line
    ss.set_displacement(dx, dy);