I am trying to style a raster in GeoServer using a SLD file. I have 850 individual values, but only 179 color mappings (i.e., unique RGBA codes). I want to keep all 850 values, as they are meaningful, but the SLD file fails to style with more than 255 color mappings (even if < 255 distinct colors are used).

Is there a way in which I can maintain all 850 values and still style the raster with the SLD?

The work around I can see would be to create a "styling raster" that reclasses each of the 850 values to a color-mapping indicator, but this is less than desirable due to the loss of meaningful information and the redundant raster layer.

Example code to give you a better idea of what I'm talking about:

  <sld:ColorMapEntry color="#eeb241" quantity="255" label="255th value"/>
  <sld:ColorMapEntry color="#eeb241" quantity="256" label="256th value"/>

The styling from the SLD fails here. Note that the colors are the same in the above two lines (e.g., unique color number 179), but the quantities have exceeded 255.

Edit 1

The quantity to color mappings unfortunately are not organized logically, and thus I am unsure that an extended intervals type SLD will do the trick. The ColorMapEntrys look more like:

<ColorMap type="intervals">
  <ColorMapEntry color="#ffffff" quantity="3001" label="1st value"/>
  <ColorMapEntry color="#ffffff" quantity="3002" label="2nd value"/>
  <ColorMapEntry color="#0000ff" quantity="3003" label="3rd value"/>
  ... other values ...
  <ColorMapEntry color="#ffffff" quantity="3089" label="89th value"/>

So, there you can see that white is being mapped to many values, but the quantities are not organized in a logical fashion that groups the color mapping together.


If you want to colour adjacent values with the same colour you could use the interval option to ColorMap as you only have 179 colours to apply. This colours all the values between the intervals the colour in the lower ColorMapEntry until they equal or exceed the next entry.

<ColorMap type="intervals" extended="true">
    <ColorMapEntry color="#EEBE2F" quantity="-300" label="label" opacity="0"/>
    <ColorMapEntry color="#DDB02C" quantity="600" label="label" opacity="1"/>

  • This is useful, but I don't think will quite achieve what I want. Unfortunately the 179 colors are not organized in a logical fashion -- i.e., they are not grouped together but are rather dispersed throughout the dataset randomly by quantity. I've edited my question to better convey this. Do you know of a way to deal with this?
    – jbukoski
    Jul 6 '17 at 0:29

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.