[GIS] GeoServer/GeoWebCache – showing raster layers depending on scale (zoom level)

geoservergeowebcache

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, thank you.

—- 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):

  <NamedLayer>
    <Name>raster-0-50k</Name>
    <UserStyle>
    <!-- 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 -->
      <FeatureTypeStyle>
        <Rule>
          <Name>rule1</Name>
          <Title>Opaque Raster</Title>
          <Abstract>A raster with 100% opacity</Abstract>
          <MaxScaleDenominator>50000</MaxScaleDenominator>
          <RasterSymbolizer>
            <Opacity>1.0</Opacity>
          </RasterSymbolizer>
        </Rule>
      </FeatureTypeStyle>
    </UserStyle>
  </NamedLayer>

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.

Best Answer

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.

Related Question