Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am editing an SLD style from the cookbook. I ahve a polygon layer, that I want to style according to the attribute (Name of the block). I want each block to have a different color. So I used the PropertyIsEqualTo rule but its giving me this error:

<?xml version="1.0" encoding="UTF-8" standalone="no"?><!DOCTYPE ServiceExceptionReport SYSTEM "http://localhost:8080/geoserver/schemas/wms/1.1.1/WMS_exception_1_1_1.dtd"> <ServiceExceptionReport version="1.1.1" >   <ServiceException>
      The requested Style can not be used with this layer.  The style specifies an attribute of ID and the layer is: ECB:reds
</ServiceException></ServiceExceptionReport>

Please help.. ECB is a workspace and the layer name is reds... the attribute value that I am using is Name.

<?xml version="1.0" encoding="ISO-8859-1"?>
<StyledLayerDescriptor version="1.0.0"
    xsi:schemaLocation="http://www.opengis.net/sld StyledLayerDescriptor.xsd"
    xmlns="http://www.opengis.net/sld"
    xmlns:ogc="http://www.opengis.net/ogc"
    xmlns:xlink="http://www.w3.org/1999/xlink"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <NamedLayer>
    <Name>Attribute-based polygon</Name>
    <UserStyle>
      <Title>Attribute-based polygon</Title>
      <FeatureTypeStyle>
        <Rule>
          <Name>ID</Name>
          <Title>Nored</Title>
          <ogc:Filter>
            <ogc:PropertyIsEqualTo>
              <ogc:PropertyName>ID</ogc:PropertyName>
              <ogc:Literal>NORED</ogc:Literal>
            </ogc:PropertyIsEqualTo>
          </ogc:Filter>
          <PolygonSymbolizer>
            <Fill>
              <CssParameter name="fill">#F5A9F2</CssParameter>
            </Fill>
          </PolygonSymbolizer>
        </Rule>
        <Rule>
          <Name>Cenored</Name>
          <Title>Cenored</Title>
          <ogc:Filter>
            <ogc:PropertyIsEqualTo>
              <ogc:PropertyName>ID</ogc:PropertyName>
              <ogc:Literal>CENORED</ogc:Literal>
            </ogc:PropertyIsEqualTo>
          </ogc:Filter>
          <PolygonSymbolizer>
            <Fill>
              <CssParameter name="fill">#F3F781</CssParameter>
            </Fill>
          </PolygonSymbolizer>
        </Rule>
         <Rule>
          <Name>ErongoRed</Name>
          <Title>ErongoRed</Title>
          <ogc:Filter>
            <ogc:PropertyIsEqualTo>
              <ogc:PropertyName>ID</ogc:PropertyName>
              <ogc:Literal>ERONGORED</ogc:Literal>
            </ogc:PropertyIsEqualTo>
          </ogc:Filter>
          <PolygonSymbolizer>
            <Fill>
              <CssParameter name="fill">#FFFFFF</CssParameter>
            </Fill>
          </PolygonSymbolizer>
        </Rule>
         <Rule>
          <Name>SouthernRed</Name>
          <Title>SouthernRed</Title>
          <ogc:Filter>
            <ogc:PropertyIsEqualTo>
              <ogc:PropertyName>ID</ogc:PropertyName>
              <ogc:Literal>SOUTHERNRED</ogc:Literal>
            </ogc:PropertyIsEqualTo>
          </ogc:Filter>
          <PolygonSymbolizer>
            <Fill>
              <CssParameter name="fill">#F6CEF5</CssParameter>
            </Fill>
          </PolygonSymbolizer>
        </Rule>
        <Rule>
          <Name>CentralRed</Name>
          <Title>CentralRed</Title>
          <ogc:Filter>
            <ogc:PropertyIsEqualTo>
              <ogc:PropertyName>ID</ogc:PropertyName>
              <ogc:Literal>CENTRALRED</ogc:Literal>
            </ogc:PropertyIsEqualTo>
          </ogc:Filter>
          <PolygonSymbolizer>
            <Fill>
              <CssParameter name="fill">#819FF7</CssParameter>
            </Fill>
          </PolygonSymbolizer>
        </Rule>
      </FeatureTypeStyle>
    </UserStyle>
  </NamedLayer>
</StyledLayerDescriptor>

thats my sld.. sorry the attribute field is id.

share|improve this question
    
Could you include the SLD code? –  Guy Aug 19 '13 at 9:22
    
I cant post it its saying its too long... am quite new here can I perhaps send it to you then you help me? –  Susan Aug 19 '13 at 9:32
    
You could try using a paste-and-share tool (e.g. gist.github.com) –  Guy Aug 19 '13 at 9:40
    
Set the NamedLayer Name element to the name of your layer - ECB:Red –  mixedbredie Aug 19 '13 at 10:02
    
do you have an attribute called ID in your dataset? note this is case sensetive? –  iant Aug 19 '13 at 10:42

2 Answers 2

What Editor are you using. SLD are not meant to be edited directly in text editors. Instead use uDIG or QGIS to style your layer then export the Style in SLD format and thenimport it in Geoserver. This way you will be much faster and accurate. Atlas Styler is specifically made to style data.

share|improve this answer
    
I am using Notepad++.. I tried that..its working but when I add the labels on then they are not showing in geoserver... –  Susan Aug 21 '13 at 14:43
1  
Labels should show up. uDIG allows to see the sld file inside program and make changes. I suggest you open the layer in uDIG and experiment there. –  neogeomat Aug 21 '13 at 15:34
    
I dont have uDIG and am quite not familiar to it.... –  Susan Aug 22 '13 at 9:21
2  
Get it here. udig.refractions.net. Its just another gis. It is easy. –  neogeomat Aug 22 '13 at 14:04

You don't say where your SLD is being used - GeoServer? QGIS?

This is what I use on a polygon layer from PostGIS in GeoServer. The layer is topographicarea, the field is descriptive_group and the attribute value is building. The layer is filtered by field and attribute and then a style is applied to each classification.

  <NamedLayer>
    <se:Name>topographicarea</se:Name>
    <UserStyle>
      <se:Name>topographicarea</se:Name>
      <se:FeatureTypeStyle>
        <se:Rule>
          <se:Name>Building</se:Name>
          <se:Description>
            <se:Abstract>Building</se:Abstract>
          </se:Description>
          <ogc:Filter>
            <ogc:PropertyIsEqualTo>
              <ogc:PropertyName>descriptive_group</ogc:PropertyName>
              <ogc:Literal>Building</ogc:Literal>
            </ogc:PropertyIsEqualTo>
          </ogc:Filter>
          <se:PolygonSymbolizer>
            <se:Fill>
              <se:SvgParameter name="fill">#ffcc99</se:SvgParameter>
            </se:Fill>
          </se:PolygonSymbolizer>
        </se:Rule>
        <se:Rule>
          <se:Name>General Surface</se:Name>
          <se:Description>
            <se:Abstract>General Surface - Manmade</se:Abstract>
          </se:Description>
          <ogc:Filter>
            <ogc:And>
              <ogc:PropertyIsEqualTo>
                <ogc:PropertyName>descriptive_group</ogc:PropertyName>
                <ogc:Literal>General Surface</ogc:Literal>
              </ogc:PropertyIsEqualTo>
              <ogc:PropertyIsEqualTo>
                <ogc:PropertyName>make</ogc:PropertyName>
                <ogc:Literal>Manmade</ogc:Literal>
              </ogc:PropertyIsEqualTo>
            </ogc:And>
          </ogc:Filter>
          <se:PolygonSymbolizer>
            <se:Fill>
              <se:SvgParameter name="fill">#cccc99</se:SvgParameter>
            </se:Fill>
          </se:PolygonSymbolizer>
        </se:Rule>

And so on through all the different features.

share|improve this answer
    
My SLD is used in geoserver dear.. Thank you I will go through this quickly... and again where do I click to post my sld code so u see it? –  Susan Aug 19 '13 at 9:35
    
You could edit your orginal post and just copy and paste the first few rules in your SLD, then style them with the preformatted code button {}. –  mixedbredie Aug 19 '13 at 9:40

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.