Creating and using a Styled Layer Descriptor

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
Example 1: santaclara_default.xml
Example 2: santaclara_pointSymbolizer.xml
Example 3: santaclara_lineSymbolizer.xml
Example 4: santaclara_polygonSymbolizer.xml
Example 5: santaclara_textSymbolizer.xml

Creating the SantaClara service

  1. Create an ArcIMS Image Service using the map configuration file SantaClara.axl, located in <ArcIMS_Installation_Directory>/Samples/TutorialData/AXL. Name it SantaClara. The service name is case sensitive. For more information on publishing a service, see Publishing an ArcIMS service.
  2. Enable WMS on the Image Service SantaClara created in step 1. For more information on enabling WMS, see Using the WMS Connector Administrator.
  3. Create a folder called sld in your ArcIMS Website directory. SLD XML documents that you create should go in this directory.
  4. Test your SantaClara WMS by typing or copying the URL below in a browser. This request uses a non-SLD GetMap request.
    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.

SantaClara - non-SDL request

top

Example 1: santaclara_default.xml

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.

GetMap Request (HTTP GET) using santaclara_default.xml SLD:

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.


GetMap Response from WMS

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.

SantaClara using santaclara_default.xml

top

Example 2: santaclara_pointSymbolizer.xml

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>

GetMap Request (HTTP GET) using santaclara_pointSymbolizer.xml SLD

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.

GetMap Response from WMS

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.

SantaClara using santaclara_pointSymbolizer.xml

top

Example 3: santaclara_lineSymbolizer.xml

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>

GetMap Request (HTTP GET) using santaclara_lineSymbolizer.xml SLD

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

GetMap Response from WMS

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.

SantaClara with santaclara_lineSymbolizer.xml

top

Example 4: santaclara_polygonSymbolizer.xml

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>

GetMap Request (HTTP GET) using santaclara_polygonSymbolizer.xml SLD:

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

GetMap Response from WMS

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.

SantaClara with santaclara_polygonSymbolizer.xml

top

Example 5: santaclara_textSymbolizer.xml

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>

GetMap Request (HTTP GET) using santaclara_textSymbolizer.xml SLD:

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.

SantaClara with santaclara_textSymbolizer.xml

top