2

I'm having a hard time dealing with geotiff images on a geoserver: I can't seem to get rid of the black 'no data' background around my geotiff image (a map area with a transparent background).

Further clarification: the geoTiff is in a geoserver layer group, and not a layer of its own, and it has the geoserver 'default' raster style on it (nothing but an opacity setting).

By default, my colour image is a black and white one; I can set the colour channels through the layer style, but that strips the alpha info (as I read elsewhere).

Setting the 'transparent colour' (to #000000) in the geoserver layer specifications doesn't seem to work, either.

I also see a place in the layer-specific page where we can set the channels/bands (there are five in mine, but the first four are rgba, verified by gdalinfo) to certain values (range, 'unit' (?)), but I can find no documentation on this.

Can anyone enlighten me?

  • Which GeoServer version? What is the bit depth of your GeoTiff? Did you try using JAI-Ext? Is the nodata value set in the GeoTiff? – pLumo Dec 5 '17 at 10:01
1

GeoServer can only make use of the Alpha Channel when the GeoTiff has 4 channels (RGBA). Similarly, OutputTransparentColor only works on RGB / RGBA 8 bit images.

As your GeoTiff has 5 channels, your best bet is to add a layer mask to your GeoTiffs.

gdal_translate ... -mask the_mask.tif ...

Or add vector footprints as sidecar files (.shp or .wkt).

Note: You will also need to select the RGB channels in the Style.

1

Thank you all for your answers; they helped me in my understanding of how GeoTiff works.

It turns out that the program I was editing the image in was adding a 'mystery channel/bamd' right after the rgb bands, which bumped the alpha channel to the fifth slot, and geoserver took the fourth one (the 'mystery band' that had a 255 value for every pixel) for the alpha.

An oversight on my behalf (and perhaps a problem other than geotiff/geoserver), but perhaps this note about this behaviour might be useful to others with a similar problem.

I managed to find what was causing the 'mystery channel' and remove it, and, lo, the geotiff behaved normally (with the server style set to only an 'opacity' command).

-1

Pre-processing the GeoTiff with gdalwarp has worked for me:

gdalwarp -of Gtiff -dstalpha input.tif output.tif

From here:

-dstalpha: Create an output alpha band to identify nodata (unset/transparent) pixels.

  • see my answer: this does only work for RGB, which is not the case here. And referring to the Question, OP already has an alpha band – pLumo Dec 5 '17 at 16:06

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.