A Styled Layer Descriptor (SLD) addresses the need for users and software to be able to control the visual portrayal of geospatial data. The ability to define styling rules requires a styling language that the client and server can both understand. The SLD provides a map-styling protocol for communicating with an OGC® Web Map Service (WMS) about the appearance of map layers.
Symbols used in map layers are described in the OpenGIS® Symbology Encoding Implementation Specification.
The Styled Layer Descriptor specificationwas developed by the Open Geospatial Consortium (OGC).
Additional Information: Styled Layer Descriptor (SLD)
Development of the SLD Specification
In 2007 the SLD specification was split into two new specifications:
- OpenGIS® Styled Layer Descriptor Profile of the Web Map Service Implementation Specification; and
- OpenGIS® Symbology Encoding Implementation Specification.
The Styled Layer Descriptor Implementation Specification now includes only the protocol for communicating with a Web Map Service (WMS) about how to style a layer; the actual description of the symbols in the layer is now provided exclusively in the Symbology Encoding Implementation Specification, which allowsthe elements not specific to WMS to be reused by other map service specifications, such as the Web Feature Service (WFS) and Web Coverage Service (WCS).
Map Styling Layers
A Styled Layer Descriptor (SLD) is an add-on capability for a OpenGIS® Web Map Service (WMS) Implementation Specification. The SLD Profile of a WMS defines an encoding that extends the WMS standard, to enable the application of the OpenGIS® Symbology Encoding Implementation Specification to WMS layers using extensions of WMS operations. Additionally, SLD defines an operation for standardized access to legend symbols.
The information presented here describes the SLD to a level sufficient to permit anyone to understand the use of a SLD in the overall context of the CGDI. The requirement to support a geospatial data infrastructure based on a distributed and cooperative service model is what distinguishes the SLD approach from other approaches. The overall objective is to provide interoperable web mapping services where the appearance of a single integrated map dynamically generated from a large infrastructure is consistent and follows standard map layering and symbolization requirements.
SLD elements describe how user-defined symbolization can be achieved, by introducing user-defined layers and styles with rules, and their relationship with symbols using Symbology Encoding (SE). A SLD is used by a WMS to symbolize features based on the content of a SLD document. From a conceptual point-of-view, the appearance of a map can be described in terms of "styled layers". A styled layer can be considered as a transparent sheet with features symbolized upon it using SE. A map would therefore be composed of a number of "styled layers" assembled in a specified order. A simple or very complex map can be created by adding or removing styled layers within a SLD document. Conceptually a layer defines a stream of features and SE defines how those features are symbolized.
In the context of this document, a Styled Layer Descriptor (SLD) is used by a Web Map Service implemented in accordance with the OGC® Web Map Service (WMS) specification. The SLD enhances the appearance of a map by allowing user-defined symbolization, Symbology Encoding (SE). Based on the OGC® WMS specification, a map is obtained using a GetMap operation. This is precisely the mechanism used to implement a Styled Layer Descriptor to enhance the capability of a WMS. A SLD contains the appearance of a map using XML encoding.
Layers and Styles
The "Layers and Styles" section of a SLD document includes the following:
- NamedLayer which uses the "name" attribute to identify a layer known to the WMS and contains zero or more styles, either NamedStyles or UserStyles. In the absence of any styles the default style for the layer is used; and
- UserLayer that is user-defined and may contain one or more UserStyles. A UserLayer may also direct a WMS service to a specified Web Feature Service (WFS) server for access to feature data. Multiple feature types can be included in a UserLayer since this is semantically equivalent to a NamedLayer. All feature types of a UserLayer come from the same Web Feature Service (WFS). A UserStyle allows user-defined styling and is semantically equivalent to a named style in the sense that a named style could be viewed as a reference to a UserStyle stored inside of a map server. A UserStyle may contain one or more Rules which allow conditional rendering of symbols.
A Rule is used to attach a condition to a layer and group individual symbols for rendering. Only a single feature-type can be referenced inside of a Rule declaration.
The SLD Architecture presented in Figure 1 illustrates the role played by a SLD in three typical implementations of a rendering engine. The structure of the SLD, represented by its XML document type definition (DTD) and its content represented by the XML document, form a common model used by all types of rendering engines. Each different rendering engine supported by a Web Map Service has been SLD-enabled. This implies that each WMS can advertise its SLD capability and respond to a map request comprising a Styled Layer Descriptor.
Enhancing the WMS GetCapabilities
The GetCapabilities operation of a Web Map Service interface can be accessed using either HTTP GET or HTTP POST. The XML document returned from a GetCapabilities request to a WMS would provide all the necessary information to allow any client application to formulate a valid map request. For example, the capabilities document of a WMS includes all NamedLayers known to a WMS. A GetMap request is therefore not valid if it references a NamedLayer not known to a WMS. To ensure valid interaction with WMS supporting the SLD, the capabilities response of WMS needs to be enhanced to include the following information:
- Support for SLD,
- Support for user-defined layers,
- Support for user-defined styles,
- Support access to remote WFS,
- Support for HTTP GET and POST methods.
A WMS that does not support NamedLayers and NamedStyles, for example, is indicated by not returning any Layer elements in its GetCapabilities XML document. This approach makes it possible to support user-defined styles without supporting user-defined layers.
GetMap Request Using SLD
Two methods have been defined to allow client applications to use SLD and user-defined symbology:
Method #1: The client application interacts with a WMS using HTTP GET but the request references a remote SLD.
Method #2: The client application interacts with the WMS using HTTP POST with a request encoded in XML and including a SLD.
It is important to note that in both cases the WMS has no prior knowledge of the content of the SLD.
Method #1: This method allows any client application to switch between a number of pre-defined maps, each one controlled by its own pre-defined SLD. The following example illustrates a GetMap request using an SLD and the HTTP GET method:
Version=1.0.8& REQUEST=GetMap& SRS=EPSG:4326& BBOX=0.0,0.0,1.0,1.0& LAYERS=Rivers, Roads, Houses& STYLES=CenterLine, CenterLine, Outline& WIDTH=400& HEIGHT=400& FORMAT=PNG
Method #2: This method allows client applications to interactively define how they wish a map to appear by constructing SLD “on-the-fly”. The following example illustrates the method used to communicate with a WMS is HTTP POST, which requires an XML encoding of the map request:
<?xml version=”1.0” encoding=”UTF-8”?> <!DOCTYPE GetMap SYSTEM “GetMap.DTD”> <GetMap>
<PNG /> <PNG />
</Format> <BoundingBox SRS=”EPSG:4326” minx=”0.0” miny=”0.0” maxx=”1.0” maxy=”1.0” /> <!- - Embedded StyledLayerDescriptor starts here. - - > <StyledLayerDescriptor>
</NamedLayer> < NamedLayer name=”Roads”>
</NamedLayer> < NamedLayer name=”Houses”>
</StyledLayerDescriptor> <!- - Embedded StyledLayerDescriptor ends here. - - > <Width>