I am trying to style a land cover map scheme II, on Geoserver. The sld has no errors. However, the raster value/color on the image couldn't match with the raster color/image/label on the sld. Below is the sld.

 <?xml version="1.0" ?>
    <sld:StyledLayerDescriptor version="1.0.0" xmlns="http://www.opengis.net/sld" xmlns:gml="http://www.opengis.net/gml" xmlns:ogc="http://www.opengis.net/ogc" xmlns:sld="http://www.opengis.net/sld">
                            <sld:ColorMap type="intervals">
                                <sld:ColorMapEntry color="#e3ffff" label="No Data" opacity="1.0" quantity="0"/>
                                <sld:ColorMapEntry color="#009600" label="Dense Forest" opacity="1.0" quantity="1"/>
                                <sld:ColorMapEntry color="#00ad00" label="Moderate Forest" opacity="1.0" quantity="2"/>
                                <sld:ColorMapEntry color="#00db00" label="Sparse Forest" opacity="1.0" quantity="3"/>
                                <sld:ColorMapEntry color="#99bf56" label="Planted Forest" opacity="1.0" quantity="4"/>
                                <sld:ColorMapEntry color="#003d00" label="Mangrove Forest" opacity="1.0" quantity="5"/>
                                <sld:ColorMapEntry color="#7c2800" label="Woodland" opacity="1.0" quantity="6"/>
                                <sld:ColorMapEntry color="#cccc00" label="Closed Grassland" opacity="1.0" quantity="7"/>
                                <sld:ColorMapEntry color="#ffff00" label="Open Grassland" opacity="1.0" quantity="8"/>
                                <sld:ColorMapEntry color="#a0512d" label="Closed Bushland" opacity="1.0" quantity="9"/>
                                <sld:ColorMapEntry color="#cc6838" label="Open Bushland" opacity="1.0" quantity="10"/>
                                <sld:ColorMapEntry color="#ff82ff" label="Perennial Cropland" opacity="1.0" quantity="11"/>
                                <sld:ColorMapEntry color="#ff9bbf" label="Annual Cropland" opacity="1.0" quantity="12"/>
                                <sld:ColorMapEntry color="#00eded" label="Wetland" opacity="1.0" quantity="13"/>
                                <sld:ColorMapEntry color="#0000ff" label="Water Body" opacity="1.0" quantity="14"/>
                                <sld:ColorMapEntry color="#949494" label="Settlement" opacity="1.0" quantity="15"/>
                                <sld:ColorMapEntry color="#ffffbc" label="Bare Soil" opacity="1.0" quantity="16"/>
                                <sld:ColorMapEntry color="#ff7f00" label="Rock Outcrop" opacity="1.0" quantity="17"/>
                                <sld:ColorMapEntry color="#ffffff" label="Ice Cap" opacity="1.0" quantity="18"/>
                                <sld:ColorMapEntry color="#93c6a5" label="Salt Crust" opacity="1.0" quantity="19"/>
                                <sld:ColorMapEntry color="#c1c6ff" label="Cloud" opacity="1.0" quantity="20"/>
                                <sld:ColorMapEntry color="#000000" label="Shadow" opacity="1.0" quantity="21"/>

Expected image - as shown with ArcGIS/QGIS or any image editing software:

enter image description here

The Legend Preview of the above SLD:

enter image description here

When applying the above SLD, Geoserver shows the following:

enter image description here

Geoserver versions tested: 2.3, 2.11.

Is there anything I am missing?


For that kind of colormap you want to use type="values" to avoid interpolation, see documentation:



ColorMaps are tricky as they are designed to interpolate the colours between the values you specify, the SLD reference gives more details:

Pixels with values equal to or less than the minimum value are rendered with the bottom color (and opacity). Pixels with values equal to or great than the maximum value are rendered with the top color and opacity. The colors for values in between are automatically interpolated, making creating color gradients easy.

For your raster you actually want to use the recode function which will assign a colour to each value directly, such as:

     <CssParameter name="fill">
       <ogc:Function name="Recode">
         <!-- Value to transform -->
         <ogc:Function name="strTrim">

         <!-- Map of input to output values -->
         <ogc:Literal>N Eng</ogc:Literal>

         <ogc:Literal>Mid Atl</ogc:Literal>

         <ogc:Literal>S Atl</ogc:Literal>

         <ogc:Literal>E N Cen</ogc:Literal>

         <ogc:Literal>E S Cen</ogc:Literal>

         <ogc:Literal>W N Cen</ogc:Literal>

         <ogc:Literal>W S Cen</ogc:Literal>



to produce a map like:

enter image description here

  • Thank you for the answer. Does PolygonSymbolizer work for geotif? – wondim Sep 11 '17 at 19:01
  • No you would need to use a RasterSymbolizer – Ian Turton Sep 11 '17 at 19:01
  • That is noted. However, I used <ColorMap type="intervals"> that works for deseret values. But that didn't work too. I have to update my question there. I have fixed the issue by manually changing the color codes which took me about two hours! – wondim Sep 11 '17 at 19:11

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.