0

i am working with geoserver to publish some wms services. One of them is a temperature overview. With the help of my styling file (SLD) i am coloring up each tile of the map depending on its value. This works fine, but the legend does not show up as expected. I can't find the issue in my SLD file.

<?xml version="1.0" encoding="ISO-8859-1"?>
<StyledLayerDescriptor version="1.0.0" 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" xmlns:gml="http://www.opengis.net/gml" 
 xsi:schemaLocation="http://www.opengis.net/sld">
  <NamedLayer>
    <Name>temp_overview</Name>
    <UserStyle>
      <Title>Temperature Overview</Title>
      <FeatureTypeStyle>
        <Rule>
          <Title>temperature overview</Title>
          <RasterSymbolizer>
            <Opacity>1.0</Opacity>
            <ColorMap>
              <ColorMapEntry color="#2F32EA" quantity="0.0" label="0&#176;C" />
              <ColorMapEntry color="#956C80" quantity="7.5" />
              <ColorMapEntry color="#FAA615" quantity="15.0" label="15&#176;C" />
              <ColorMapEntry color="#FA540C" quantity="22.5" />   
              <ColorMapEntry color="#FA0202" quantity="30.0" label="30&#176;C" />
            </ColorMap>
          </RasterSymbolizer>
        </Rule>
        <Rule>
            <PolygonSymbolizer>
               <Fill>
                 <CssParameter name="fill">
                   <ogc:Function name="Interpolate">
                     <ogc:PropertyName>dTa</ogc:PropertyName>
                     <ogc:Literal>0</ogc:Literal>
                     <ogc:Literal>#2F32EA</ogc:Literal>

                     <ogc:Literal>7.5</ogc:Literal>
                     <ogc:Literal>#956C80</ogc:Literal>

                     <ogc:Literal>15</ogc:Literal>
                     <ogc:Literal>#FAA615</ogc:Literal>

                     <ogc:Literal>22.5</ogc:Literal>
                     <ogc:Literal>#FA540C</ogc:Literal>

                     <ogc:Literal>30</ogc:Literal>
                     <ogc:Literal>#FA0202</ogc:Literal>

                     <ogc:Literal>color</ogc:Literal>
                   </ogc:Function>
                 </CssParameter>
               </Fill>
            </PolygonSymbolizer>
        </Rule>
      </FeatureTypeStyle>
    </UserStyle>
   </NamedLayer>
</StyledLayerDescriptor>

The corresponding getLegendGraphic call shows up the following graphic:

enter image description here

5
  • is your data a raster or a polygon? it doesn't entirely make sense to apply both Symbolizers
    – Ian Turton
    Commented Aug 14, 2019 at 7:14
  • Both geom types are available. It is a raster but i also got the polygons
    – Lukas
    Commented Aug 14, 2019 at 7:27
  • but not in the same layer? make 2 SLDs
    – Ian Turton
    Commented Aug 14, 2019 at 7:34
  • 1
    GeoServer does not have a datasource that can serve a mix of rasters and polygons. E.g., if you have a geopackage, you'll have to create two separate stores, one to serve the raster part, one to serve the vector part. If you have a NetCDF instead, only rasters can be read from there. Commented Aug 14, 2019 at 7:46
  • my fault - i got polygons in my dataset now. Is it possible to get a interpolated legend (like a colormap of type ramp) out of this dataset?
    – Lukas
    Commented Aug 14, 2019 at 9:17

1 Answer 1

2

"One disadvantage of using these functions for styling is that they are not displayed in WMS legend graphics." (https://docs.geoserver.org/stable/en/user/styling/sld/tipstricks/transformation-func.html)

ok, it is not possible to build a WMS legend graphic for this transformation.

1
  • That's indeed correct. Commented Aug 16, 2019 at 8:41

Your Answer

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

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