Styling in real world units

By default, SLD interprets all sizes expressed in the style sheet (e.g., line widths, symbol sizes) as being pixels on the map.

It is however possible to make the style sheet use real world units, e.g., meters or feet, by specifying the desired unit of measure as an attribute of the symbolizer. The supported unit of measure are:

  • meter
  • foot
  • pixel

The following line style uses a line width of 40 meters:

<LineSymbolizer uom="">
    <CssParameter name="stroke">#000033</CssParameter>
    <CssParameter name="stroke-width">40</CssParameter>

Setting up an uom based style in GeoServer

  1. Create a new style named line40m using the following SLD:

    <?xml version="1.0" encoding="ISO-8859-1"?>
    <StyledLayerDescriptor version="1.0.0"
     xsi:schemaLocation=" StyledLayerDescriptor.xsd"
          <Title>40 meter wide line</Title>
              <LineSymbolizer uom="">
                  <CssParameter name="stroke">#000033</CssParameter>
                  <CssParameter name="stroke-width">40</CssParameter>


    The CSS equivalent of this style is:

    * {
      stroke: #000033;
      stroke-width: 40m;
  2. Associate the line40m style to MainRd layer as a secondary style:


    Adding the line40m style as a secondary style for Mainrd

  3. Preview the MainRd layer and switch to the line40m style:


    An uom based line, zoomed out

  4. Zoom in and out and observe how the width of the line on screen varies by changing the zoom level


Zooming in on the same line