Legend Examples

May 7, 2026 · View on GitHub

The GetLegendGraphic operation returns a legend image for a named layer + style combination. Test inputs are in test/input/wms_getlegendgraphic_*.get and expected SVG outputs in test/output/wms_getlegendgraphic_*.get; the PNG previews on this page are rasterised from those SVGs and live in docs/images/legends/.

All requests use the shared template:

GET /wms?service=WMS&request=GetLegendGraphic&version=1.3.0&sld_version=1.1.0
    &layer=<layer>&style=<style>&format=image/svg%2Bxml[&language=<lang>] HTTP/1.0
ParameterDescription
requestAlways GetLegendGraphic for this page
layerLayer to render the legend for
styleStyle to use; empty selects the layer default
sld_versionSLD version (required by the WMS spec)
formatAlways image/svg+xml here
languageOptional translation key — en, fi, sv

Contents


Automatic Legends

The default legend is generated automatically by reading isoband colour definitions from the product CSS. English and Finnish renderings of the same test:precipitation layer differ only in the localized labels.

wms_getlegendgraphic_automatic — Default automatic legend

Input: test/input/wms_getlegendgraphic_automatic.getlayer=test:precipitation

wms_getlegendgraphic_automatic

wms_getlegendgraphic_automatic_fi — Finnish translation

Input: test/input/wms_getlegendgraphic_automatic_fi.getlanguage=fi

wms_getlegendgraphic_automatic_fi

wms_getlegendgraphic_automatic_isoband_labels — Isoband label legend

Input: test/input/wms_getlegendgraphic_automatic_isoband_labels.getlayer=test:t2m_isoband_labels

Legend for the layer that draws contour value labels along the isoband boundaries.

wms_getlegendgraphic_automatic_isoband_labels

wms_getlegendgraphic_automatic_isoband_labels_fi — Isoband label legend (Finnish)

Input: test/input/wms_getlegendgraphic_automatic_isoband_labels_fi.get

wms_getlegendgraphic_automatic_isoband_labels_fi


Style Variants

Three named isoband styles for the test:t2m layer plus two isoline styles for test:precipitation exercise the &style= selector. Each English/Finnish pair shares the same colour ramp; only the labels are localized.

Isoband — temperature_one_degrees (1°C bands)

TestImage
wms_getlegendgraphic_automatic_isoband_style1style1
wms_getlegendgraphic_automatic_isoband_style1_fistyle1_fi

Isoband — temperature_two_degrees (2°C bands)

TestImage
wms_getlegendgraphic_automatic_isoband_style2style2
wms_getlegendgraphic_automatic_isoband_style2_fistyle2_fi

Isoband — temperature_three_degrees (3°C bands)

TestImage
wms_getlegendgraphic_automatic_isoband_style3style3
wms_getlegendgraphic_automatic_isoband_style3_fistyle3_fi

Isoline — precipitation_thin_style

TestImage
wms_getlegendgraphic_automatic_isoline_style1isoline1
wms_getlegendgraphic_automatic_isoline_style1_fiisoline1_fi

Isoline — precipitation_thick_style

TestImage
wms_getlegendgraphic_automatic_isoline_style2isoline2
wms_getlegendgraphic_automatic_isoline_style2_fiisoline2_fi

Modified and Product-Specific Templates

wms_getlegendgraphic_automatic_modified — Per-layer overrides

Input: test/input/wms_getlegendgraphic_automatic_modified.getlayer=test:precipitation_modified

Layer JSON overrides individual legend rows (custom labels, omitted bands) on top of the automatic CSS-derived ramp.

wms_getlegendgraphic_automatic_modified

wms_getlegendgraphic_automatic_modified_fi — Modified, Finnish

Input: test/input/wms_getlegendgraphic_automatic_modified_fi.get

wms_getlegendgraphic_automatic_modified_fi

wms_getlegendgraphic_automatic_product_specific_template — Custom CTPP2 template

Input: test/input/wms_getlegendgraphic_automatic_product_specific_template.getlayer=test:t2m

The test:t2m layer specifies its own legend SVG template (legend_template: in the layer config), replacing the default vertical stack with a custom layout.

wms_getlegendgraphic_automatic_product_specific_template

wms_getlegendgraphic_automatic_product_specific_template_fi — Custom template, Finnish

Input: test/input/wms_getlegendgraphic_automatic_product_specific_template_fi.get

wms_getlegendgraphic_automatic_product_specific_template_fi


Multilingual Translations

The test:snow_drift_index layer carries title and band-label translations for English, Finnish, and Swedish. The &language= parameter selects which translation file is rendered into the legend.

TestLanguageImage
wms_getlegendgraphic_automatic_translation_enenen
wms_getlegendgraphic_automatic_translation_fififi
wms_getlegendgraphic_automatic_translation_svsvsv

Internal Legends

When the product JSON embeds an explicit legend: block, the server uses that definition instead of deriving one from CSS.

wms_getlegendgraphic_internal_legend — Embedded legend block

Input: test/input/wms_getlegendgraphic_internal_legend.getlayer=test:t2m_p

wms_getlegendgraphic_internal_legend

wms_getlegendgraphic_internal_legend_fi — Embedded legend, Finnish

Input: test/input/wms_getlegendgraphic_internal_legend_fi.get

wms_getlegendgraphic_internal_legend_fi


External Legends

The layer can also point to an external SVG file, optionally selecting a named style block within it.

wms_getlegendgraphic_external_legend — Default external legend

Input: test/input/wms_getlegendgraphic_external_legend.getlayer=test:wind_legend

wms_getlegendgraphic_external_legend

wms_getlegendgraphic_external_legend_fi — External legend, Finnish

Input: test/input/wms_getlegendgraphic_external_legend_fi.get

wms_getlegendgraphic_external_legend_fi

wms_getlegendgraphic_external_legend_alternative_style — Named style block

Input: test/input/wms_getlegendgraphic_external_legend_alternative_style.getstyle=alternative_legend_style1

Selects an alternative style block within the same external legend SVG.

wms_getlegendgraphic_external_legend_alternative_style

wms_getlegendgraphic_external_legend2 — Second external legend file

Input: test/input/wms_getlegendgraphic_external_legend2.getlayer=test:wind_legend2

A second external legend layer, demonstrating that multiple external legend files can coexist.

wms_getlegendgraphic_external_legend2