1

I want to encode data using a colormap using GeoServer/RasterSymbolizer, by mapping data using the full 24 bits in RGB. I am thinking of the following scheme:

<ColorMap type="ramp"> <ColorMapEntry color="#7FFE00" quantity="-512"/> <ColorMapEntry color="#7FFFFF" quantity="-256"/> <ColorMapEntry color="#800000" quantity="0"/> <ColorMapEntry color="#8001FF" quantity="256"/> <ColorMapEntry color="#800200" quantity="512"/> <ColorMapEntry color="#8003FF" quantity="768"/> </ColorMap>

However, I am not completely sure this will work, as I could not find documentation on the RasterSymolizer. Between two color values, only the B channel (last two symbols) should change.

A value of 257 using this colormap, would be interpolated between #8001FF and #800200. I hope this would encode to #8001FE, but theoretically it could also be #8002FE.

Alternatively, I could double the entries in the colormap to make it more explicit, like so:

<ColorMapEntry color="#7FFEFF" quantity="-256"/> <ColorMapEntry color="#7FFF00" quantity="-256"/> <ColorMapEntry color="#7FFFFF" quantity="0"/> <ColorMapEntry color="#800000" quantity="0"/> <ColorMapEntry color="#8000FF" quantity="256"/> <ColorMapEntry color="#800100" quantity="256"/> <ColorMapEntry color="#8001FF" quantity="512"/> <ColorMapEntry color="#800200" quantity="512"/>

Is it allowed to have two entries for the same quantity?

A third option is like below:

<ColorMapEntry color="#7FFEFF" quantity="-257"/> <ColorMapEntry color="#7FFF00" quantity="-256"/> <ColorMapEntry color="#7FFFFF" quantity="-1"/> <ColorMapEntry color="#800000" quantity="0"/> <ColorMapEntry color="#8000FF" quantity="255"/> <ColorMapEntry color="#800100" quantity="256"/> <ColorMapEntry color="#8001FF" quantity="511"/> <ColorMapEntry color="#800200" quantity="512"/>

How will a value of 255.5 will interpolated in this case? #800180 or #800080? Following the encoding scheme it should be #8000FF. Note that the input data is stored as a geotiff with float32's.

  • Why not look at the code? – Ian Turton Feb 26 '16 at 17:24
  • also have you looked at the SLD specification to answer your second question? – Ian Turton Feb 26 '16 at 21:21
2

You can have GeoServer use 64k color using the option extended="true" in the ramp; mind you this will make thing slower as there will be more colors to render.

That said, the rendering code tries to equally split the available colors (256 or 64k) between the available buckets (N+1 where N is the number of breakpoints.

Then values are mapped into colors through linear interpolation.

This means it is hard to predict which colors a value will be mapped to unless the value is used as a breakpoint in the ramps.

Aside, in the colormap you should not use two different breakpoints with the same quantity.

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.