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 have an uncompressed GeoTIFF file (figure 1) with the following band information:

Image Structure Metadata:
   INTERLEAVE=PIXEL
Band 1 Block=5000x1 Type=Byte, ColorInterp=Red
Band 2 Block=5000x1 Type=Byte, ColorInterp=Green
Band 3 Block=5000x1 Type=Byte, ColorInterp=Blue
Band 4 Block=5000x1 Type=Byte, ColorInterp=Undefined

Original RGB image
Figure 1

I have compressed the file using the following set of parameters:

gdal_translate -of gtiff -co compress=jpeg -co jpeg_quality=85 -co tiled=yes -co photometric=rgb uncompressed.tif compressed.tif

This gives me a file with the following information:

Image Structure Metadata:
  COMPRESSION=JPEG
  INTERLEAVE=PIXEL
Band 1 Block=256x256 Type=Byte, ColorInterp=Red
Band 2 Block=256x256 Type=Byte, ColorInterp=Green
Band 3 Block=256x256 Type=Byte, ColorInterp=Blue
Band 4 Block=256x256 Type=Byte, ColorInterp=Undefined

Problem:
When I serve my compressed image through GeoServer 2.1.4 I get image in figure 2 instead of the image in figure 1, which is what I would like. My goal is to have GeoServer just display the first three bands as RGB and ignore the 4th band.

4 band image in GeoServer 2.1.4
Figure 2

I have tried to style the raster layer in GeoServer using SLD by adding the following channel configuration, but it didn't help.

<ChannelSelection>
    <RedChannel>
        <SourceChannelName>1</SourceChannelName>
    </RedChannel>
    <GreenChannel>
        <SourceChannelName>2</SourceChannelName>
    </GreenChannel>
    <BlueChannel>
        <SourceChannelName>3</SourceChannelName>
    </BlueChannel>
</ChannelSelection>

Why is my image server through GeoServer 2.1.4 looking the way it is and how do I configure GeoServer to display the image 'correctly'?

share|improve this question
add comment

1 Answer

up vote 5 down vote accepted

I don't know how GDAL handles JPEG compression on a four band raster, it does not make much sense to me, JPEG is meant to be used against RGB (three band) or gray (one band) images. When you gdal_translate it you can also shave off the fourth band with, I believe, -b 1 -b 2 -b 3

share|improve this answer
    
I guess you're right about JPEG and the number of bands. I had hoped to avoid doing any alterations to the original data set nor creating a specialised set just for GeoServer. But a 3-band data set is probably the way to go. Interesting though how GDAL handles multi-band JPEG compressed GeoTIFFs. Thanks for your answer! –  Chau Jun 7 '12 at 12:52
1  
I also don't know how gdal handles JPEG compression but I would try to use interleave=band instead of the default interleave=pixel and a recent version of GDAL (1.9 at least). –  user12040 Oct 17 '12 at 11:28
add comment

Your Answer

 
discard

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.