I have a client application, "talking" to my GeoWebCache service (using TMS), showing a map. The map is built out or a few raster layers. I need to show only one of them a time - depending on the zoom level (scale), one of the layers should be shown - the rest not visible.

The client can use only one "link" to access the map - I cannot switch the layers on the client.

I created a group layer on GeoServer (2.1.4) built out of the two layers I am using (250k and StreetView from OS). I cannot see any way to specify that one of them should be seen when the scale is less then N and the other otherwise. I tried a style for raster layer, specifying opacity depending on the scale, but it does not seem to work. How is it done on GeoServer?

If it is doable on GeoWebCache level, that would be fine too. I successfully added the layers to geowebcache.xml file (I need the EPSG:27700 projection, that is why the config was needed), but cannot find a way of saying "use this WMS URL when scale is less than N".

Any help will be much appreciated.

---- UPDATE after the answer - the solution ----

I have two styles created, called raster-0-50k and raster-50k-up. Here is the first one of them, which I applied to the layer at the bottom of the stack (the top one in the list of the group layer):

    <!-- Styles can have names, titles and abstracts -->
      <Title>Raster 0 to 50k</Title>
      <Abstract>Raster, showing scale 0 to 50000</Abstract>
      <!-- FeatureTypeStyles describe how to render different features -->
      <!-- A FeatureTypeStyle for rendering rasters -->
          <Title>Opaque Raster</Title>
          <Abstract>A raster with 100% opacity</Abstract>

the other style does exactly opposite - sets opacity to 1 for scale 50k and higher. In the group layer's list, I associated the two styles with my two layers.

It does work now :) Thank you.

1 Answer 1


You need to specify a min/max scale denominator in your SLD files. Use the same figure in each style, that is the max in one is the min in the other, so that only one layer is drawn at any scale. Then combine the layers in a layer group and away you go. See http://docs.geoserver.org/stable/en/user/styling/sld/reference/rules.html#scale-selection for more details on the syntax.

  • Thank you, iant. I have applied your suggestion and it helped. Can you have a look at my update above - I put there one of the styles. There is still some problem with the GeoServer processing both (all) the layers. Is there any way to stop this happening?
    – mapuser
    Jun 15, 2012 at 9:09
  • Just leave out rule2 - if the rule doesn't apply at the scale requested then nothing will be drawn.
    – Ian Turton
    Jun 15, 2012 at 9:33
  • It does work! Thanks a lot :) I will update the xml above to show the final result. I was assuming that if no rule applies to the NamedLayer element, the layer would be rendered with some default style. I was wrong.
    – mapuser
    Jun 15, 2012 at 11:03

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.