Opened 13 years ago

Closed 12 years ago

#4234 closed defect (fixed)

Problem with ECW files in MapServer using PROCESSING "BANDS=..."

Reported by: armin Owned by: warmerdam
Priority: normal Milestone: 1.10.0
Component: GDAL_Raster Version: unspecified
Severity: normal Keywords: ECW


I noticed a strange behaviour of Mapserver (5.6.7 and 6.0.1) when defining for a raster layer based on an ECW file a processing parameter for the bands order like


The order of the bands does not have any effect. The image is always displayed in the original band order 1,2,3, whatever I define for the BANDS value. If I just define a single band, like "BANDS=3" or "BANDS=1" then it's displaying it correctly using the right band.

This problem seems just to appear for ECW files, not e.g. for Tiff files. If I wrap a VRT image around the ECW and use this VRT in the DATA tag of the map file then the BANDS order is taken into account, just not when defining the DATA using the pure ECW file.

The problem appears both with GDAL 1.8 and trunk-2011-09-04.

Comment from Frank Warmerdam on Mapserver mailing list: "I suspect that the special interleaved read method in the GDAL ECW driver is not properly honouring the list of bands passed in to it"

Change History (6)

comment:1 by warmerdam, 13 years ago

Component: defaultGDAL_Raster
Keywords: ECW added
Status: newassigned

comment:2 by warmerdam, 13 years ago

I have confirmed that the following script produces the same result whether the source band list is [3,2,1] or [1,2,3].

#!/usr/bin/env python

from osgeo import gdal

ds = gdal.Open('data/ecw/golf_course.ecw')
data = ds.ReadRaster( 0, 0, ds.RasterXSize, ds.RasterYSize, 
                      ds.RasterXSize, ds.RasterYSize,
                      gdal.GDT_Byte, [3,2,1] )

drv = gdal.GetDriverByName('GTiff')
ds_out = drv.Create( 'out.tif', ds.RasterXSize, ds.RasterYSize, 3,
                     gdal.GDT_Byte )

ds_out.WriteRaster( 0, 0, ds.RasterXSize, ds.RasterYSize,
                    data, ds.RasterXSize, ds.RasterYSize,
                    gdal.GDT_Byte, [1,2,3] )
ds_out = None
ds = None

comment:3 by warmerdam, 13 years ago

I have tracked down into ECWDataset::IRasterIO() and the band list is being passed into poFileView->SetView(). As far as I can tell it is having no effect. Note, I am testing with the 3.3 library. I haven't tested it with more recent versions which might be illuminating.

comment:4 by armin, 13 years ago

I also used so far just the older 3.3 ECW library.

comment:5 by Even Rouault, 13 years ago

I have tested Frank's script with SDK 4.2 and it works as expected (the order of bands specified is taken into account), so it looks like a defect of the SDK 3.3

comment:6 by Even Rouault, 12 years ago

Milestone: 2.0.0
Resolution: fixed
Status: assignedclosed

r25107 "ECW: workaround a ECW SDK 3.3, and the ECW format, when doing a RasterIO() with the total number of bands, but not in the 1,2,..n order (#4234)"

Note: See TracTickets for help on using tickets.