1

I have to produce a xml file, according to Styled Layer Descriptor (SLD) (for more informations you can see: http://www.opengeospatial.org/standards/sld). The file is required by GeoServer and it has the purpose to add a color legend. How would this xml file be written, according to standard SLD ? Can you indicate me some link with examples?

Thank you for your attention.

Best regards, B.O.

1

You need to read about "MaxScaleDenominator" and "MinScaleDenominator" in this page, and then define the "size" for each range.

See this example:

<?xml version="1.0" encoding="UTF-8"?>
<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"
    xsi:schemaLocation="http://www.opengis.net/sld http://schemas.opengis.net/sld/1.0-.0/StyledLayerDescriptor.xsd">
    <NamedLayer>
        <Name>layer</Name>
        <UserStyle>
            <Name>default</Name>
            <FeatureTypeStyle>
                <Rule>
                   <!--Change here the scale of this range -->
                   <MaxScaleDenominator>20000</MaxScaleDenominator>
                   <PointSymbolizer>
                     <Graphic>
                        <ExternalGraphic>
                            <!--put here the image link -->
                            <OnlineResource xlink:type="simple"
                                xlink:href="/path/to/image.png" />
                            <Format>image/png</Format>
                        </ExternalGraphic>
                       <!--Define here the size of this range -->
                       <Size>10</Size>
                     </Graphic>
                   </PointSymbolizer>
                </Rule>
                <Rule>
                   <!--Change here the scale of this range -->
                   <MinScaleDenominator>20000</MinScaleDenominator>
                   <PointSymbolizer>
                     <Graphic>
                        <ExternalGraphic>
                            <!--put here the image link -->
                            <OnlineResource xlink:type="simple"
                                xlink:href="/path/to/image.png" />
                            <Format>image/png</Format>
                        </ExternalGraphic>
                       <!--Define here the size of this range -->
                       <Size>4</Size>
                     </Graphic>
                   </PointSymbolizer>
                </Rule>
            </FeatureTypeStyle>
        </UserStyle>
    </NamedLayer>
</StyledLayerDescriptor>
| improve this answer | |
0

If you want to change the values of the pixels then you need a RasterSymbolizer and a ColorRamp - see the SLD Cookbook for examples. For a "rainbow" type image look at http://docs.geoserver.org/latest/en/user/styling/sld-cookbook/rasters.html#many-color-gradient

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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