I have a raster with two bands. Both bands only have ones and zeros. I want to apply the following style:

Band1    Band2    Color
  0        0      #000000
  0        1      #ff0000
  1        0      #ffff00
  1        1      #ffffff

So I want to apply a style considering values on both bands, I searched on GeoServer documentation but I didn't find any similar example

1 Answer 1


I think the only way to do this is to transform it into a single band and color that in the normal way. Fortunately, GeoServer provides a way to do this using Rendering Transformations and Jiffle.

Something like (untested):

      <ogc:Function name="ras:Jiffle">
        <ogc:Function name="parameter">
        <ogc:Function name="parameter">
            b1 = src[1];
            b2 = src[2];
            dest = (b1*2)+b2;
        <ColorMap type="values">
          <ColorMapEntry color="#000000" quantity="0"/>
          <ColorMapEntry color="#ff0000" quantity="1"/>
          <ColorMapEntry color="#ffff00" quantity="2"/>
          <ColorMapEntry color="#ffffff" quantity="3"/>

Note: the use of values in the color map to color only pixels that match that value.

  • Thanks, I have tested it and works perfectly
    – David1212k
    Jun 11, 2020 at 9:39

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.