2

I would like to use Geoserver SLD to style points using one attribute for the size in mapunits and the second attribute for the colour.

This works well as separate rules styling either the colour or the size of the symbol.

This is for Geoserver 2.8

I don't get any result by combining the rules like so:

        <ogc:And>
          <ogc:And>
            <ogc:And>
              <ogc:PropertyIsGreaterThanOrEqualTo>
                <ogc:PropertyName>tt_grid</ogc:PropertyName>
                <ogc:Literal>818</ogc:Literal>
              </ogc:PropertyIsGreaterThanOrEqualTo>
              <ogc:PropertyIsLessThanOrEqualTo>
                <ogc:PropertyName>tt_grid</ogc:PropertyName>
                <ogc:Literal>159174</ogc:Literal>
              </ogc:PropertyIsLessThanOrEqualTo>
            </ogc:And>
            <ogc:PropertyIsGreaterThanOrEqualTo>
              <ogc:PropertyName>y15plus_t_2014</ogc:PropertyName>
              <ogc:Literal>2.2</ogc:Literal>
            </ogc:PropertyIsGreaterThanOrEqualTo>
          </ogc:And>
          <ogc:PropertyIsLessThanOrEqualTo>
            <ogc:PropertyName>y15plus_t_2014</ogc:PropertyName>
            <ogc:Literal>7.2238</ogc:Literal>
          </ogc:PropertyIsLessThanOrEqualTo>
        </ogc:And>

Here is a screenshot directly off Ian's solution.

enter image description here

2

You can simplify your Filter by combining the And's:

<ogc:And>     
  <ogc:PropertyIsGreaterThanOrEqualTo>
    <ogc:PropertyName>tt_grid</ogc:PropertyName>
    <ogc:Literal>818</ogc:Literal>
  </ogc:PropertyIsGreaterThanOrEqualTo>
  <ogc:PropertyIsLessThanOrEqualTo>
    <ogc:PropertyName>tt_grid</ogc:PropertyName>
    <ogc:Literal>159174</ogc:Literal>
  </ogc:PropertyIsLessThanOrEqualTo>
  <ogc:PropertyIsGreaterThanOrEqualTo>
    <ogc:PropertyName>y15plus_t_2014</ogc:PropertyName>
    <ogc:Literal>2.2</ogc:Literal>
  </ogc:PropertyIsGreaterThanOrEqualTo>
  <ogc:PropertyIsLessThanOrEqualTo>
    <ogc:PropertyName>y15plus_t_2014</ogc:PropertyName>
    <ogc:Literal>7.2238</ogc:Literal>
  </ogc:PropertyIsLessThanOrEqualTo>
</ogc:And>

which may fix the issue, but you probably want to use a Between filter:

<ogc:And>
    <ogc:PropertyIsBetween>
         <ogc:PropertyName>tt_grid</ogc:PropertyName>
         <ogc:LowerBoundary><ogc:Literal>818</ogc:Literal></ogc:LowerBoundary>
         <ogc:UpperBoundary><ogc:Literal>159174</ogc:Literal></ogc:UpperBoundary>
    </ogc:PropertyIsBetween>
    <ogc:PropertyIsBetween>
         <ogc:PropertyName>y15plus_t_2014</ogc:PropertyName>
         <ogc:LowerBoundary><ogc:Literal>2.2</ogc:Literal></ogc:LowerBoundary>
         <ogc:UpperBounadry><ogc:Literal>7.2238</ogc:Literal></ogc:UpperBoundary>
    </ogc:PropertyIsBetween>
 </ogc:And>

Finally if you have a large number of classes you might want consider using some maths functions to calculate the size of the point directly from the relevant property so you have jut N classes instead of N*M classes.

  • I have tried to substitute your sugestion but get following error for every ogc:LowerBoundary and ogc:UpperBoundary block. line 17: cvc-complex-type.2.3: Element 'ogc:LowerBoundary' cannot have character [children], because the type's content type is element-only. line 17: cvc-complex-type.2.4.b: The content of element 'ogc:LowerBoundary' is not complete. One of '{"opengis.net/ogc":expression}' is expected. – Dennis Bauszus Dec 1 '15 at 13:57
  • they need a literal then - I'll edit – Ian Turton Dec 1 '15 at 13:58
  • That worked for the LowerBoundary blocks but not for the UpperBoundary blocks. I still get line 18: cvc-complex-type.2.4.a: Invalid content was found starting with element 'ogc:UpperBounadry'. One of '{"opengis.net/ogc":UpperBoundary}' is expected. – Dennis Bauszus Dec 1 '15 at 14:04
  • a typo :-) I'll fix – Ian Turton Dec 1 '15 at 14:05
  • yes. off course. should have seen this myself. been looking for too long at sld xml today. smashing solution. works perfect. i update question with screenshot. – Dennis Bauszus Dec 1 '15 at 14:24

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.