1

I want to use an external SLD (hosted in my server) for symbolizing a raster in GeoServer.

The SLD below works if used as default style in GeoServer. If I copy it (changing some colors) and put outside GeoServer, save as SLD (or XML), and call the GetMap with SLD=https://my_server/mySLD.sld the map I get is still with the 'default, Geoserver' style

<StyledLayerDescriptor version="1.0.0" 
xsi:schemaLocation="http://www.opengis.net/sld StyledLayerDescriptor.xsd" 
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:se="http://www.opengis.net/se">
  <NamedLayer>
    <Name>my_schema:my_layer</Name>
    <UserStyle>
      <FeatureTypeStyle>
               <Rule>
                    <RasterSymbolizer>
                        <Geometry>
                           <PropertyName>GRAY_INDEX</PropertyName>
                        </Geometry>
                        <Opacity>1</Opacity>
                        <ColorMap>
                           <ColorMapEntry color="#E69800" label="1" opacity="0.0" quantity="0.0"/>                     
                            <ColorMapEntry color="#1b4bde" label="Building" opacity="1.0" quantity="1.0"/>
                            <ColorMapEntry color="#bcbcbc" label="Ground cover" opacity="1.0" quantity="2.0"/>
                                 
                    </ColorMap>
       </RasterSymbolizer>
      </Rule>
      </FeatureTypeStyle>
    </UserStyle>
    </NamedLayer>    
  </StyledLayerDescriptor>

shortly, WMS call would be like this (also tried withou STYLES param) https://my_geoserver_url/wms?service=WMS&version=1.1.0&request=GetMap&layers=my_schema:my_layer&STYLES=&SLD=https://my_server/my_sld.sld&transparent=true&bbox=...&format=image/png

I did this for dynamic filtering in vector data and all good (SLDs are created dynamically via PHP), so I am wondering if the problem is that with RASTER data is not possible

1 Answer 1

1

When the style is used in GeoServer, it gets stripped of everything but the first UserStyle/NamedStyle, and that part is used to render the layer, blindly (that's not conforming to standard, but also the behavior GeoServer had for the past 15-20 years, everyone relies on it).

When using a remote style instead, you get the full standard compliant treatment instead. Long story short, your Style must have a NamedLayer matching your layer name and must be marked as the default style. See the library mode documentation for more details

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.