Is there any way to use the conditional statement in SLD based on scale to set parameter for example:

  • for scale between 25001 and 50 000 set size 15
  • for scale between 5001 and 25 000 set size 28
  • for scale between 400 and 5000 set size 40

I have rule like this


                  <CssParameter name="stroke">#004d26</CssParameter>
                  <CssParameter name="stroke-width">3</CssParameter>          
              <Size>15</Size> <!--  tighter pattern -->
          <CssParameter name="fill-opacity"> 
            <ogc:Function name="env">
          <CssParameter name="stroke">#004d26</CssParameter>
          <CssParameter name="stroke-width">0.2</CssParameter>
          <CssParameter name="stroke-opacity">
            <ogc:Function name="env">


2 Answers 2


In GeoServer 2.20 you can mark a rule for usage just in the map, or just in the legend:


Set the two rules you want to hide as "mapOnly" and they should disappear from the legend.


No, each rule with it's scale dependencies is independent of the other rules so you can simply specify the size (or colour or whatever) in that rule.

If having multiple rules causes issue for your legend then pass in the scale to the getLegend request as described in the manual.

  • OK, thank you, but in that case in the legend I will have three types of symbology somekind for the same thing, is it possible to avoid it? for example to have only one symbol, hide the other 2 in the legend
    – ncica
    Oct 21, 2021 at 10:54
  • somehow hide a rule from the GetLegendGraphics?
    – ncica
    Oct 21, 2021 at 11:01
  • @ncica, did you find a solution to your question? Apr 4, 2022 at 11:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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