1

I have a problem with the Styling for the contour-lines. here is how I want to style them:

  1. 4 different classes with different display zoom MaxScaleDenominator.
  2. The interval is a variable (not fixed) based on user what to choose.
  3. most important is Rule number 4 that shows all the contour-lines with the elevation higher than 500, but the most important part is, I don't want to show all bands(all lines) just each 5 band.(leads us to render fewer lines on the map, that is why I used the IEEERemainder).

But simply it doesn't work with the tag PropertyIsGreaterThan but it works with the PropertyIsEqualTo tag, but this tag problem is, doesn't work with interval ex. 43.

Is there any solution to fix it or another approach for my purpose?

<?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>CL</Name>
        <UserStyle>
            <Title>CL</Title>
            <Abstract>CL</Abstract>
            <FeatureTypeStyle>
                <Rule>
                    <Name>rule 1</Name>
                    <Title>CL (all)</Title>
                    <MaxScaleDenominator>40000</MaxScaleDenominator>
                    <LineSymbolizer>
                        <Stroke>
                            <CssParameter name="stroke">#006600</CssParameter>
                            <CssParameter name="stroke-width">1</CssParameter>
                        </Stroke>
                    </LineSymbolizer>
                </Rule>
                <Rule>
                    <Name>rule 2</Name>
                    <Title>CL (50)</Title>
                    <ogc:Filter>
                        <ogc:And>
                            <ogc:PropertyIsEqualTo>
                                <ogc:Function name="IEEERemainder">
                                    <ogc:Function name="int2ddouble">
                                        <ogc:PropertyName>value</ogc:PropertyName>
                                    </ogc:Function>
                                    <ogc:Function name="parseDouble">
                                        <ogc:Literal>50.0</ogc:Literal>
                                    </ogc:Function>
                                </ogc:Function>
                                <ogc:Literal>0</ogc:Literal>
                            </ogc:PropertyIsEqualTo>
                            <ogc:PropertyIsBetween>
                                <ogc:PropertyName>value</ogc:PropertyName>
                                <ogc:LowerBoundary>
                                    <ogc:Literal>50</ogc:Literal>
                                </ogc:LowerBoundary>
                                <ogc:UpperBoundary>
                                    <ogc:Literal>200</ogc:Literal>
                                </ogc:UpperBoundary>
                            </ogc:PropertyIsBetween>
                        </ogc:And>
                    </ogc:Filter>
                    <MaxScaleDenominator>120000</MaxScaleDenominator>
                    <LineSymbolizer>
                        <Stroke>
                            <CssParameter name="stroke">#8600b3</CssParameter>
                            <CssParameter name="stroke-width">1</CssParameter>
                        </Stroke>
                    </LineSymbolizer>
                </Rule>
                <Rule>
                    <Name>rule 3</Name>
                    <Title>CL (200)</Title>
                    <ogc:Filter>
                        <ogc:PropertyIsBetween>
                            <ogc:Function name="IEEERemainder">
                                <ogc:Function name="int2ddouble">
                                    <ogc:PropertyName>value</ogc:PropertyName>
                                </ogc:Function>
                                <ogc:Function name="parseDouble">
                                    <ogc:Literal>200.0</ogc:Literal>
                                </ogc:Function>
                            </ogc:Function>
                            <ogc:LowerBoundary>
                                <ogc:Literal>200</ogc:Literal>
                            </ogc:LowerBoundary>
                            <ogc:UpperBoundary>
                                <ogc:Literal>500</ogc:Literal>
                            </ogc:UpperBoundary>
                        </ogc:PropertyIsBetween>
                    </ogc:Filter>
                    <MaxScaleDenominator>150000</MaxScaleDenominator>
                    <LineSymbolizer>
                        <Stroke>
                            <CssParameter name="stroke">#3366ff</CssParameter>
                            <CssParameter name="stroke-width">1</CssParameter>
                        </Stroke>
                    </LineSymbolizer>
                </Rule>
                <Rule>
                    <Name>Rule 4</Name>
                    <Title>CL (500)</Title>
                    <ogc:Filter>
                        <ogc:PropertyIsGreaterThan>
                            <ogc:Function name="IEEERemainder">
                                <ogc:Function name="int2ddouble">
                                    <ogc:PropertyName>value</ogc:PropertyName>
                                </ogc:Function>
                                <ogc:Function name="parseDouble">
                                    <ogc:Literal>500.0</ogc:Literal>
                                </ogc:Function>
                            </ogc:Function>
                            <ogc:Literal>0</ogc:Literal>
                        </ogc:PropertyIsGreaterThan>
                    </ogc:Filter>
                    <LineSymbolizer>
                        <Stroke>
                            <CssParameter name="stroke">#ff0000</CssParameter>
                            <CssParameter name="stroke-width">1</CssParameter>
                        </Stroke>
                    </LineSymbolizer>
                </Rule>
            </FeatureTypeStyle>
        </UserStyle>
    </NamedLayer>
</StyledLayerDescriptor>
1

Your filter is not working the way you think it does.

You are trying to limit the number of contours drawn which is normally done by applying a filter that is equivalent to value%x==0 where x is the "space" between contours.

But you are using values of x that are much too large to get any results (especially when combined with the other parts of your filter).

Here is an example with some of my data:

enter image description here

Unfiltered contours every 10m

enter image description here

Every other contour (i.e. 20m contours)

Using:

    <Rule>
      <Name>Rule 4</Name>
      <Title>CL (500)</Title>
      <ogc:Filter>
        <ogc:PropertyIsEqualTo>
          <ogc:Function name="IEEERemainder">
            <ogc:Function name="int2ddouble">
              <ogc:PropertyName>propertyVa</ogc:PropertyName>
            </ogc:Function>
            <ogc:Literal>20.0</ogc:Literal>
          </ogc:Function>
          <ogc:Literal>0</ogc:Literal>
        </ogc:PropertyIsEqualTo>
      </ogc:Filter> 
      <LineSymbolizer>
        <Stroke>
          <CssParameter name="stroke">#ff0000</CssParameter>
          <CssParameter name="stroke-width">1</CssParameter>
        </Stroke>
      </LineSymbolizer>
    </Rule>

and now every 50m

enter image description here

with this filter:

     <ogc:Filter>
        <ogc:PropertyIsEqualTo>
          <ogc:Function name="IEEERemainder">
            <ogc:Function name="int2ddouble">
              <ogc:PropertyName>propertyVa</ogc:PropertyName>
            </ogc:Function>
            <ogc:Literal>50.0</ogc:Literal>
          </ogc:Function>
          <ogc:Literal>0</ogc:Literal>
        </ogc:PropertyIsEqualTo>
      </ogc:Filter> 
  • you are absolutely right,if you change each time the <ogc:Literal>50.0</ogc:Literal>, but problem is , I have one SLD file in GeoServer and the intervals is chosen by the user. Now how should I handle if the user choose the 57 as an interval. – GeoCom Nov 15 '17 at 10:07
  • you need to look at variables - docs.geoserver.org/stable/en/user/styling/sld/extensions/… – Ian Turton Nov 16 '17 at 9:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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