To create a Styled Layer Descriptor, you need to create a valid XML document that follows the OGC SLD schema, which can be found at http://schemas.opengis.net/sld/1.0.0/StyledLayerDescriptor.xsd.
The following examples demonstrate how to create and use a Styled Layer Descriptor XML document. These examples use an ArcIMS service named "SantaClara", which is part of the ArcIMS tutorial data.
Creating the SantaClara service| http://localhost/wmsconnector/com.esri.wms.Esrimap/SantaClara?VERSION=1.1.1&REQUEST=GetMap&SRS=EPSG:4326&LAYERS=0,1,2,3,4,5,6&STYLES=&BBOX=-122.22733445000001,36.87499618530274,-121.18332155000002,37.5&FORMAT=image/png&WIDTH=720&HEIGHT=360 |
The returned image should look like the following.
In Example 1, santaclara_default.xml SLD is used. This SLD XML does not allow any customization on layer symbolization. Instead, it tells the WMS Server to render all listed layers in their default style.
|
<?xml version="1.0" encoding="ISO-8859-1"?> <sld:StyledLayerDescriptor version="1.0.0" xmlns:sld="http://www.opengis.net/sld" xmlns:ogc="http://www.opengis.net/ogc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <sld:NamedLayer> <sld:Name>0</sld:Name> <sld:NamedStyle> <sld:Name></sld:Name> nbsp; </sld:NamedStyle> </sld:NamedLayer> <sld:NamedLayer> <sld:Name>1</sld:Name> <sld:NamedStyle> <sld:Name></sld:Name> </sld:NamedStyle> </sld:NamedLayer> <sld:NamedLayer> <sld:Name>2</sld:Name> <sld:NamedStyle> <sld:Name></sld:Name> </sld:NamedStyle> </sld:NamedLayer> <sld:NamedLayer> <sld:Name>3</sld:Name> <sld:NamedStyle> <sld:Name></sld:Name> </sld:NamedStyle> </sld:NamedLayer> <sld:NamedLayer> <sld:Name>4</sld:Name> <sld:NamedStyle> <sld:Name></sld:Name> </sld:NamedStyle> </sld:NamedLayer> <sld:NamedLayer> <sld:Name>5</sld:Name> <sld:NamedStyle> <sld:Name></sld:Name> </sld:NamedStyle> </sld:NamedLayer> <sld:NamedLayer> <sld:Name>6</sld:Name> <sld:NamedStyle> <sld:Name></sld:Name> </sld:NamedStyle> </sld:NamedLayer> </sld:StyledLayerDescriptor> |
Since this SLD does not allow any customization on layer symbolization, using the GetMap request below renders the same map as the one created from a non-SLD GetMap request.
|
http://localhost/wmsconnector/com.esri.wms.Esrimap/SantaClara? VERSION=1.1.1&REQUEST=GetMap&SRS=EPSG:4326&BBOX=122.22733445000001,36.87499618530274, -121.18332155000002,37.5&FORMAT=image/png&WIDTH=720&HEIGHT=360&SLD= http://localhost/website/sld/santaclara_default.xml |
Note: Hard returns were inserted for readability.
The image below is the response from WMS when the URL of santaclara_default.xml is assigned to the SLD parameter in the GetMap request.
In Example 2, santaclara_pointSymbolizer.xml customizes the point feature layer cities (Layer ID=5) using a user-style in which points will be rendered with square for WellKnownName, #0000ff for fill color, #ffffff for border color, 10 for point size, and 0.5 for opacity.
|
<?xml version="1.0"
encoding="ISO-8859-1"?> <sld:StyledLayerDescriptor version="1.0.0" xmlns:sld="http://www.opengis.net/sld" xmlns:ogc="http://www.opengis.net/ogc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <sld:NamedLayer> <sld:Name>0</sld:Name> <sld:NamedStyle> <sld:Name></sld:Name> </sld:NamedStyle> </sld:NamedLayer> <sld:NamedLayer> <sld:Name>1</sld:Name> <sld:NamedStyle> <sld:Name></sld:Name> </sld:NamedStyle> </sld:NamedLayer> <sld:NamedLayer> <sld:Name>2</sld:Name> <sld:NamedStyle> <sld:Name></sld:Name> </sld:NamedStyle> </sld:NamedLayer> <sld:NamedLayer> <sld:Name>3</sld:Name> <sld:NamedStyle> <sld:Name></sld:Name> </sld:NamedStyle> </sld:NamedLayer> <sld:NamedLayer> <sld:Name>4</sld:Name> <sld:NamedStyle> <sld:Name></sld:Name> </sld:NamedStyle> </sld:NamedLayer> <sld:NamedLayer> <sld:Name>5</sld:Name> <sld:UserStyle> <sld:Name>user_style_city</sld:Name> <sld:FeatureTypeStyle> <sld:Rule> <sld:PointSymbolizer> <sld:Graphic> <sld:Mark> <sld:WellKnownName>square</sld:WellKnownName> <sld:Fill> <sld:CssParameter name="fill">#0000ff</sld:CssParameter> </sld:Fill> <sld:Stroke> <sld:CssParameter name="stroke">#ffffff</sld:CssParameter> </sld:Stroke> </sld:Mark> <sld:Opacity>0.5</sld:Opacity> <sld:Size>10</sld:Size> </sld:Graphic> </sld:PointSymbolizer> </sld:Rule> </sld:FeatureTypeStyle> </sld:UserStyle> </sld:NamedLayer> <sld:NamedLayer> <sld:Name>6</sld:Name> <sld:NamedStyle> <sld:Name></sld:Name> </sld:NamedStyle> </sld:NamedLayer> </sld:StyledLayerDescriptor> |
|
http://localhost/wmsconnector/com.esri.wms.Esrimap/SantaClara?VERSION=1.1.1& REQUEST=GetMap&SRS=EPSG:4326&BBOX=-122.22733445000001,36.87499618530274,-121.18332155000002,37.5&FORMAT=image/png&WIDTH=720&HEIGHT=360&SLD= http://localhost/website/sld/santaclara_pointSymbolizer.xml |
Note: Hard returns were inserted for readability.
The image below is the response from WMS when the URL of santaclara_pointSymbolizer.xml is assigned to the SLD parameter in the GetMap request. The symbolization of cities in the returned map has been changed from the default pink circle to a blue square with a white border.
In Example 3, santaclara_lineSymbolizer.xml customizes the polyline feature layer rivers (Layer ID=3) using a user-style, in which polylines are rendered as #00ff00 (green) in color, 3 pixels in width, an opacity of 1, mitre for the line join style, and square for the line cap style.
|
<?xml version="1.0"
encoding="ISO-8859-1"?> <sld:StyledLayerDescriptor version="1.0.0" xmlns:sld="http://www.opengis.net/sld" xmlns:ogc="http://www.opengis.net/ogc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <sld:NamedLayer> <sld:Name>0</sld:Name> <sld:NamedStyle> <sld:Name></sld:Name> </sld:NamedStyle> </sld:NamedLayer> <sld:NamedLayer> <sld:Name>1</sld:Name> <sld:NamedStyle> <sld:Name></sld:Name> </sld:NamedStyle> </sld:NamedLayer> <sld:NamedLayer> <sld:Name>2</sld:Name> <sld:NamedStyle> <sld:Name></sld:Name> </sld:NamedStyle> </sld:NamedLayer> <sld:NamedLayer> <sld:Name>3</sld:Name> <sld:UserStyle> <sld:Name>user_style_river</sld:Name> <sld:FeatureTypeStyle> <sld:Rule> <sld:LineSymbolizer> <sld:Stroke> <sld:CssParameter name="stroke">#00ff00</sld:CssParameter> <sld:CssParameter name="stroke-opacity">1</sld:CssParameter> <sld:CssParameter name="stroke-width">1</sld:CssParameter> <sld:CssParameter name="stroke-linejoin">mitre</sld:CssParameter> <sld:CssParameter name="stroke-linecap">square</sld:CssParameter> </sld:Stroke> </sld:LineSymbolizer> </sld:Rule> </sld:FeatureTypeStyle> </sld:UserStyle> </sld:NamedLayer> <sld:NamedLayer> <sld:Name>4</sld:Name> <sld:NamedStyle> <sld:Name></sld:Name> </sld:NamedStyle> </sld:NamedLayer> <sld:NamedLayer> <sld:Name>5</sld:Name> <sld:NamedStyle> <sld:Name></sld:Name> </sld:NamedStyle> </sld:NamedLayer> <sld:NamedLayer> <sld:Name>6</sld:Name> <sld:NamedStyle> <sld:Name></sld:Name> </sld:NamedStyle> </sld:NamedLayer> </sld:StyledLayerDescriptor> |
|
http://localhost/wmsconnector/com.esri.wms.Esrimap/SantaClara? VERSION=1.1.1&REQUEST=GetMap&SRS=EPSG:4326&BBOX=-122.22733445000001,36.87499618530274,-121.18332155000002,37.5&FORMAT=image/png&WIDTH=720&HEIGHT=360& SLD=http://localhost/website/sld/santaclara_lineSymbolizer.xml |
Note: Hard returns were inserted for readability
The image below shows the response from WMS when the URL of santaclara_lineSymbolizer.xml is assigned to the SLD parameter in the GetMap request. The symbolization of rivers in the returned map has been changed from the default thin blue line to a thicker green polyline.
In Example 4, santaclara_polygonSymbolizer.xml customizes the polygon feature layer boundary (Layer ID=0) using a user-style, in which polygons are rendered as #ff0000 (green), have a fill opacity of 0.6, a border color of #00ff00, a border opacity of 0.8, and use mitre for line join style and square for line cap style.
|
<?xml version="1.0"
encoding="ISO-8859-1"?> <sld:StyledLayerDescriptor version="1.0.0" xmlns:sld="http://www.opengis.net/sld" xmlns:ogc="http://www.opengis.net/ogc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <sld:NamedLayer> <sld:Name>1</sld:Name> <sld:NamedStyle> <sld:Name></sld:Name> </sld:NamedStyle> </sld:NamedLayer> <sld:NamedLayer> <sld:Name>2</sld:Name> <sld:NamedStyle> <sld:Name></sld:Name> </sld:NamedStyle> </sld:NamedLayer> <sld:NamedLayer> <sld:Name>3</sld:Name> <sld:NamedStyle> <sld:Name></sld:Name> </sld:NamedStyle> </sld:NamedLayer> <sld:NamedLayer> <sld:Name>4</sld:Name> <sld:NamedStyle> <sld:Name></sld:Name> </sld:NamedStyle> </sld:NamedLayer> <sld:NamedLayer> <sld:Name>5</sld:Name> <sld:NamedStyle> <sld:Name></sld:Name> </sld:NamedStyle> </sld:NamedLayer> <sld:NamedLayer> <sld:Name>6</sld:Name> <sld:NamedStyle> <sld:Name></sld:Name> </sld:NamedStyle> </sld:NamedLayer> <sld:NamedLayer> <sld:Name>0</sld:Name> <sld:UserStyle> <sld:Name>user_style_boundary</sld:Name> <sld:FeatureTypeStyle> <sld:Rule> <sld:PolygonSymbolizer> <sld:Fill> <sld:CssParameter name="fill">#ff0000</sld:CssParameter> <sld:CssParameter name="fill-opacity">0.6</sld:CssParameter> </sld:Fill> <sld:Stroke> <sld:CssParameter name="stroke">#00ff00</sld:CssParameter> <sld:CssParameter name="stroke-opacity">0.8</sld:CssParameter> <sld:CssParameter name="stroke-width">1</sld:CssParameter> <sld:CssParameter name="stroke-linejoin">mitre</sld:CssParameter> <sld:CssParameter name="stroke-linecap">square</sld:CssParameter> </sld:Stroke> </sld:PolygonSymbolizer> </sld:Rule> </sld:FeatureTypeStyle> </sld:UserStyle> </sld:NamedLayer> </sld:StyledLayerDescriptor> |
|
http://localhost/wmsconnector/com.esri.wms.Esrimap/SantaClara?VERSION=1.1.1 &REQUEST=GetMap&SRS=EPSG:4326&BBOX=-122.22733445000001,36.87499618530274,-121.18332155000002,37.5&FORMAT=image/png&WIDTH=720&HEIGHT=360&SLD= http://localhost/website/sld/santaclara_polygonSymbolizer.xml |
Below is the response from WMS when the URL of santaclara_polygonSymbolizer.xml is assigned to the SLD parameter in the GetMap request. The boundary symbolization in the map has been changed from being completely transparent to having a green border.
In Example 5, santaclara_textSymbolizer.xml customizes the point feature layer cities with text labels (Layer ID=5) using a user-style in which text labels are rendered as the value found in the NAME column, using the Arial text font family, normal text font weight, italic text font style, 12 pt text font size, 0 for label placement rotation, 3 for pixel Halo Radius, #333333 for Halo fill color, and #ffffff for text color.
|
<?xml version="1.0" encoding="ISO-8859-1"?> <sld:StyledLayerDescriptor version="1.0.0" xmlns:sld="http://www.opengis.net/sld" xmlns:ogc="http://www.opengis.net/ogc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <sld:NamedLayer> <sld:Name>0</sld:Name> <sld:NamedStyle> <sld:Name></sld:Name> </sld:NamedStyle> </sld:NamedLayer> <sld:NamedLayer> <sld:Name>1</sld:Name> <sld:NamedStyle> <sld:Name></sld:Name> </sld:NamedStyle> </sld:NamedLayer> <sld:NamedLayer> <sld:Name>2</sld:Name> <sld:NamedStyle> <sld:Name></sld:Name> </sld:NamedStyle> </sld:NamedLayer> <sld:NamedLayer> <sld:Name>3</sld:Name> <sld:NamedStyle> <sld:Name></sld:Name> </sld:NamedStyle> </sld:NamedLayer> <sld:NamedLayer> <sld:Name>4</sld:Name> <sld:NamedStyle> <sld:Name></sld:Name> </sld:NamedStyle> </sld:NamedLayer> <sld:NamedLayer> <sld:Name>5</sld:Name> <sld:UserStyle> <sld:Name>user_style_city</sld:Name> <sld:FeatureTypeStyle> <sld:Rule> <sld:TextSymbolizer> <sld:Label> <ogc:PropertyName>NAME</ogc:PropertyName> </sld:Label> <sld:Font> <sld:CssParameter name="font-family">Arial</sld:CssParameter> <sld:CssParameter name="font-weight">normal</sld:CssParameter> <sld:CssParameter name="font-style">italic</sld:CssParameter> <sld:CssParameter name="font-size">12</sld:CssParameter> </sld:Font> <sld:LabelPlacement> <sld:Rotation></sld:Rotation> </sld:LabelPlacement> <sld:Halo> <sld:Radius></sld:Radius> <sld:Fill> <sld:CssParameter name="fill">#333333</sld:CssParameter> </sld:Fill> </sld:Halo> <sld:Fill> <sld:CssParameter name="fill">#ffffff</sld:CssParameter> </sld:Fill> </sld:TextSymbolizer> </sld:Rule> </sld:FeatureTypeStyle> </sld:UserStyle> </sld:NamedLayer> <sld:NamedLayer> <sld:Name>6</sld:Name> <sld:NamedStyle> <sld:Name></sld:Name> </sld:NamedStyle> </sld:NamedLayer> </sld:StyledLayerDescriptor> |
|
http://localhost/wmsconnector/com.esri.wms.Esrimap/SantaClara?VERSION=1.1.1& REQUEST=GetMap&SRS=EPSG:4326&BBOX=-122.22733445000001,36.87499618530274,-121.18332155000002,37.5&FORMAT=image/png&WIDTH=720&HEIGHT=360&SLD= http://localhost/website/sld/santaclara_textSymbolizer.xml |
Note: Hard returns inserted for readability
GetMap Response from WMS
The map below shows the response from WMS when the URL of santaclara_textSymbolizer.xml is assigned to the SLD parameter in the GetMap request. The symbolization of text labels in the map for the cities layer has been changed from simple black text labels to white text labels with a dark gray background.