3.10.3. LineSymbolizer

The LineSymbolizer specifies how to render linear geometries like lines and polygon outlines. Most of the LineSymbolizer attributes define stroke attributes of the line to draw, like color, width, how line joins and ends should look, and even dash patterns.

There are also some attributes that change the lines geometry itself, like offset, smooth and simplify.

Table 26. LineSymbolizer
Attribute Value Default Description

clip

boolean

false

comp-op

SVG compositing

geometry-transform

SVG transform

offset

float

0

rasterize

full, fast

full

smooth

0.0 - 1.0

1

simplify

float

0

simplify-algorithm

radial-distance, zhao-saalfeld, visvalingam-whyatt, douglas-peucker

radial-distance

stroke

color

black

stroke-dasharray

number list

none

stroke-dashoffset

number list

none

experimental only

stroke-gamma

0.0 - 1.0

1

stroke-gamma-method

power, linear, none, threshold, multiply

power

stroke-linejoin

bevel, miter, miter-revert, round

miter

stroke-linecap

butt, round, square

butt

stroke-miterlimit

float

4

stroke-opacity

0.0 - 1.0

1

stroke-width

float

1

TODO: * for miterlimit see e.g. https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-miterlimit for meterlimit description / visualization * for simplify-algorithm see e.g. https://i11www.iti.kit.edu/_media/teaching/sommer2013/algokartografie/gruppe1.pdf

Example 29. LineSymbolizer smooth
<?xml version="1.0" encoding="utf-8"?>
<Map background-color='white'>

  <Style name="style">
    <Rule>
      <LineSymbolizer smooth="[smooth]"/>
      <TextSymbolizer face-name="DejaVu Sans Book" allow-overlap="true" dy="20">[smooth]</TextSymbolizer>
    </Rule>
  </Style>

  <Layer name="layer">
    <StyleName>style</StyleName>
    <Datasource>
      <Parameter name="type">csv</Parameter>
      <Parameter name="inline">
wkt,smooth
"LINESTRING(10 10,50 20,90 10)",0.0
"LINESTRING(10 20,50 30,90 20)",0.5
"LINESTRING(10 30,50 40,90 30)",1.0
      </Parameter>
    </Datasource>
  </Layer>

</Map>
smooth
Example 30. LineSymbolizer stroke
<?xml version="1.0" encoding="utf-8"?>
<Map background-color='white'>

  <Style name="style">
    <Rule>
      <LineSymbolizer stroke="[stroke]" stroke-width="5"/>
      <TextSymbolizer face-name="DejaVu Sans Book" allow-overlap="true" dy="20">[stroke]</TextSymbolizer>
    </Rule>
  </Style>

  <Layer name="layer">
    <StyleName>style</StyleName>
    <Datasource>
      <Parameter name="type">csv</Parameter>
      <Parameter name="inline">
wkt,stroke
"LINESTRING(10 10,50 20,90 10)",red
"LINESTRING(10 20,50 30,90 20)",green
"LINESTRING(10 30,50 40,90 30)",blue
      </Parameter>
    </Datasource>
  </Layer>

</Map>
stroke
Example 31. LineSymbolizer dash array
<?xml version="1.0" encoding="utf-8"?>
<Map background-color='white'>

  <Style name="style">
    <Rule>
      <LineSymbolizer stroke-dasharray="[dash]" stroke-width="5"/>
      <TextSymbolizer face-name="DejaVu Sans Book" allow-overlap="true" dy="20">[dash]</TextSymbolizer>
    </Rule>
  </Style>

  <Layer name="layer">
    <StyleName>style</StyleName>
    <Datasource>
      <Parameter name="type">csv</Parameter>
      <Parameter name="inline">
wkt,dash
"LINESTRING(10 10,50 20,90 10)","5,5"
"LINESTRING(10 20,50 30,90 20)","10,5"
"LINESTRING(10 30,50 40,90 30)","10,5,2,5"
      </Parameter>
    </Datasource>
  </Layer>

</Map>
stroke dasharray
Example 32. LineSymbolizer stroke linejoin

TODO: prevent image clipping on top edge

<?xml version="1.0" encoding="utf-8"?>
<Map background-color='white'>

  <Style name="style">
    <Rule>
      <LineSymbolizer stroke="#7F7F7F" stroke-linejoin="[join]" stroke-width="20"/>
      <LineSymbolizer stroke="#FF0000" stroke-width="1"/>
      <TextSymbolizer face-name="DejaVu Sans Book" allow-overlap="true" dy="30">[join]</TextSymbolizer>
    </Rule>
  </Style>

  <Layer name="layer">
    <StyleName>style</StyleName>
    <Datasource>
      <Parameter name="type">csv</Parameter>
      <Parameter name="inline">
wkt,join
"LINESTRING(30 30,50 50,70 30)",bevel
"LINESTRING(30 20,50 40,70 20)",round
"LINESTRING(30 10,50 30,70 10)",miter
      </Parameter>
    </Datasource>
  </Layer>

</Map>
stroke linejoin
Example 33. LineSymbolizer stroke linecap
<?xml version="1.0" encoding="utf-8"?>
<Map background-color='white'>

  <Style name="style">
    <Rule>
      <LineSymbolizer stroke="#7F7F7F" stroke-linecap="[cap]" stroke-width="20"/>
      <LineSymbolizer stroke="#FF0000" stroke-width="1"/>
      <TextSymbolizer face-name="DejaVu Sans Book" allow-overlap="true" dy="20">[cap]</TextSymbolizer>
    </Rule>
  </Style>

  <Layer name="layer">
    <StyleName>style</StyleName>
    <Datasource>
      <Parameter name="type">csv</Parameter>
      <Parameter name="inline">
wkt,cap
"LINESTRING(0 6,20 6)",but
"LINESTRING(0 3,20 3)",round
"LINESTRING(0 0,20 0)",square
      </Parameter>
    </Datasource>
  </Layer>

</Map>
stroke linecap
Example 34. LineSymbolizer stroke miter limit
<?xml version="1.0" encoding="utf-8"?>
<!-- TODO: caption text -->
<Map background-color='white'>
  
  <Style name="style">
    <Rule>
      <LineSymbolizer stroke-linejoin="miter" stroke-width="10" stroke-miterlimit="[ml]" stroke="#7f7f7f"/>
      <LineSymbolizer stroke-width="1" stroke="#FF0000"/>
      <!-- <TextSymbolizer face-name="DejaVu Sans Book" allow-overlap="true" dy="20">[cap]</TextSymbolizer> -->
    </Rule>
  </Style>

  <Layer name="layer">
    <StyleName>style</StyleName>
    <Datasource>
      <Parameter name="type">csv</Parameter>
      <Parameter name="inline">
wkt,ml
"LINESTRING(10 10,20 30,30 10)",2
"LINESTRING(14 10,20 25,26 10)",2
"LINESTRING(18 10,20 18,22 10)",2
"LINESTRING(40 10,50 30,60 10)",2.5
"LINESTRING(44 10,50 25,56 10)",2.5
"LINESTRING(48 10,50 18,52 10)",2.5
"LINESTRING(70 10,80 30,90 10)",6
"LINESTRING(74 10,80 25,86 10)",6
"LINESTRING(78 10,80 18,82 10)",6
      </Parameter>
    </Datasource>
  </Layer>

</Map>
stroke miterlimit
Example 35. LineSymbolizer stroke opacity
<?xml version="1.0" encoding="utf-8"?>
<Map background-color='white'>

  <Style name="style">
    <Rule>
      <LineSymbolizer stroke-opacity="[opacity]" stroke-width="5"/>
      <TextSymbolizer face-name="DejaVu Sans Book" allow-overlap="true" dy="20">[opacity]</TextSymbolizer>
    </Rule>
  </Style>

  <Layer name="layer">
    <StyleName>style</StyleName>
    <Datasource>
      <Parameter name="type">csv</Parameter>
      <Parameter name="inline">
wkt,opacity
"LINESTRING(10 10,50 20,90 10)",0.2
"LINESTRING(10 20,50 30,90 20)",0.5
"LINESTRING(10 30,50 40,90 30)",0.8
      </Parameter>
    </Datasource>
  </Layer>

</Map>
stroke opacity
Example 36. LineSymbolizer stroke width
<?xml version="1.0" encoding="utf-8"?>
<Map background-color='white'>

  <Style name="style">
    <Rule>
      <LineSymbolizer stroke-width="[width]"/>
      <TextSymbolizer face-name="DejaVu Sans Book" allow-overlap="true" dy="20">[width]</TextSymbolizer>
    </Rule>
  </Style>

  <Layer name="layer">
    <StyleName>style</StyleName>
    <Datasource>
      <Parameter name="type">csv</Parameter>
      <Parameter name="inline">
wkt,width
"LINESTRING(10 10,50 20,90 10)",1
"LINESTRING(10 20,50 30,90 20)",5
"LINESTRING(10 30,50 40,90 30)",10
      </Parameter>
    </Datasource>
  </Layer>

</Map>
stroke width
Example 37. LineSymbolizer offset

Note that unlike in other LineSymbolizer examples this is three times the same geometry, but with different offset.

<?xml version="1.0" encoding="utf-8"?>
<Map background-color='white'>

  <Style name="style">
    <Rule>
      <LineSymbolizer offset="[offset]"/>
      <TextSymbolizer face-name="DejaVu Sans Book" allow-overlap="true" dy="[offset]+10">[offset]</TextSymbolizer>
    </Rule>
  </Style>

  <Layer name="layer">
    <StyleName>style</StyleName>
    <Datasource>
      <Parameter name="type">csv</Parameter>
      <Parameter name="inline">
wkt,offset
"LINESTRING(10 10,50 20,90 10)",20
"LINESTRING(10 10,50 20,90 10)",0
"LINESTRING(10 10,50 20,90 10)",-20
      </Parameter>
    </Datasource>
  </Layer>

</Map>
offset

See also:

TODO: gamma, gamma-method, dash-offset, miter-limit, clip, simplify, simplify-algorithm, rasterize, geometry-transform, comp-op