Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I'm struggling to set the a background colour to transparent in an SLD file for a 4-channel GEOTIFF using GeoServer 2.1.4.

I think I've set my background colour to transparent alpha layer in a graphics package correctly.

I've set up an SLD file to read Red/Green/Blue channels of my GEOTIFF = this resolves colours correctly for the RGB image = but still shows the background black colour (see below).

When I do a GetFeatureInfo request on the WMS, I can see an ALPHA_BAND=0 where I want the transparency and ALPHA_BAND =255 where I do not want transparency (see attached figure).

enter image description here

I was hopeing to do something like setting the ALPHA_BAND=0 to Opacity=0 in the SLD or something. However, there's no option in SLD schema that I can see ?

I've read the SLD cookbook and the SLD reference documentation. Alpha transparency is referred to but only with ColorMap' property. Can I mix and match 'ColorMap' and ChannelSelection' properties in the SLD ?

Am I going about this the right way ? Thanks in advance for assistance!

This is the SLD I'm using:

    <?xml version="1.0" encoding="ISO-8859-1"?>
    <StyledLayerDescriptor version="1.0.0" xmlns="http://www.opengis.net/sld" xmlns:ogc="http://www.opengis.net/ogc"
      xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://www.opengis.net/sld http://schemas.opengis.net/sld/1.0.0/StyledLayerDescriptor.xsd">
            <Name>bathy example</Name>
              <Name>RGB image 3 channels</Name>
              <Title>RGB image</Title>
share|improve this question
I think you might want to set the NODATA value in the GeoTiff to 0. –  iant Nov 19 '12 at 13:22
Hi @iant - I don't think the raster contains NODATA values, as the the GetFeatureInfo request results in 0,0,0,0 for RGBA channels. Also, in ArcMap, the identify tool results in the same values returned as the WMS GetFeatureInfo request results. Any other ideas? Thanks for your help. –  SamFranklin Nov 19 '12 at 17:44
You need to set the nodata value -try using gdal_translate -a_nodata 0 gdal.org/gdal_translate.html –  iant Nov 20 '12 at 9:01

1 Answer 1

I faced quite a similar problem and found here and here the following statements of people working for GeoSolutions:

"The colormap element can be used only on a single band to generate an RGB(A) raster where quantities can be mapped to colors."

"You cannot apply the ColorMap element when having 3 bands, you need only 1."

I found two ways to be able to add transparency using GDAL tools:

  1. using gdalwarp as described in the link above: This adds a 4th band to the file containing a transparency mask.

    • Set nodata masking values:

      $ gdalwarp -of GTiff -srcnodata 0 -dstalpha inputfile.tif outputfile.tif
    • After that, setting the default raster style for the Geoserver layer is enough to have a transparent background.

    It is also mentioned that there are "extensions to SLD to support multiband color maps" or one could write custom WPS processes but I did not go further into that.

  2. using gdal_translate as mentioned by @ian in the comments above: This sets 'no data' values to every band (I don't really understand whats going on there).

    • Assign a specified nodata value to output bands:

      $ gdal_translate -a_nodata 0 inputfile.tif outputfile.tif
    • After that, you can set the InputTransparentColor in the Layer properties in your Geoserver Web Application to the desired value (here: 000000).

    My OpenLayers preview could not deal with such a layer when the underlying GeoTIFF was of 16bit color depth (check with gdalinfo). One can reduce it to a manageable 8bits with $ gdal_translate -ot Byte inputfile.tif outputfile.tif.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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