My GeoTIFF has 3 channels (RGB). I would like to generate a transparent output for pixels with R=0 AND G=0 AND B=0. Zero values should remain black in case there are values >0 in any other channel (e.g. 0-255-0 -> green).

I understand that <ColorMap> works for single-channel images only. So this is no option here.

I am using gdal_translate to create the GeoTIFF. Setting -a_nodata 0 though results in transparent pixels for 0-values regardless the value in other channels (i.e. 0-255-0 -> transparent).

I could possibly create an alpha channel as fourth channel. However, the imagery is rather large (>200 GB), so I want to avoid an additional increase in size and computation time.

The desired behavior can easily be achieved in QGIS by setting 0-0-0 to 100% transparent in the transparency section. (The SLD-Export does not include this behavior though.) Is there a similar way for SLD / GeoServer? Or do I have to create an alpha channel?

  • 1
    With GDAL you must use other formats than GeoTIFF for handling individual nodata values for each band. VRT supports that. I would still recommend to try adding an alpha (or mask) band. A fourth band with only two possible pixel values can be compressed effectively so maybe the file size would not increase too much.
    – user30184
    Apr 21, 2023 at 10:26
  • The case RGB: 0-255-0 that you want to "remain" black is somehow undefined. It means that the green band is at maximum and red and blue bands are NULL, and without nodata handling the result would be pure green. Maybe it would be better to say that the result should be mapped into black.
    – user30184
    Apr 21, 2023 at 12:14
  • Sorry, my example was somewhat misleading ... The result should be green here indeed, but it is set to transparent with my GDAL transform. I corrected the post accordingly.
    – luti
    Apr 21, 2023 at 12:27

1 Answer 1


The stand-alone GeoTIFF reader cannot do what you want, nor can SLD.

However, there is a simple workaround: place you GeoTIFF in a folder, and create a GeoServer image mosaic on such folder. While publishing the layer, set the "input transparent color" to black.

enter image description here

  • Thanks a lot Andrea, this actually works. But I somehow feel that there could be performance issues going alongside with this. My data is "cloud optimized" (COG). I will try this out in more detail but also take a look at user30184 suggestion to create an alpha channel at the VRT stage of image processing.
    – luti
    Apr 21, 2023 at 12:29
  • Please let us know if your "feeling" actually materializes in a measurable slowdown. Apr 21, 2023 at 14:16
  • sure :) It could take some time though ...
    – luti
    Apr 21, 2023 at 14:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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