Opened 13 years ago

Closed 13 years ago

#4146 closed defect (fixed)

SAR_CEOS driver used instead of CEOS driver for certain datasets

Reported by: rprinceley Owned by: warmerdam
Priority: normal Milestone: 1.8.1
Component: GDAL_Raster Version: unspecified
Severity: normal Keywords: SAR_CEOS
Cc: gaopeng, antonio

Description

The SAR_CEOS driver incorrectly identifies and attempts to open certain CEOS datasets. A workaround would be to change the driver order, but ideally, SAR_CEOS should have a proper Identify implementation (or more checks).

CEOS2001.I3B

Change History (6)

comment:1 by antonio, 13 years ago

Cc: antonio added

comment:2 by antonio, 13 years ago

There is something strange.

In [1]: import struct

In [2]: s = struct.Struct('>I4BI')

In [3]: fd = open('CEOS2001.I3B', 'rb')

In [4]: h = fd.read(s.size)

In [5]: s.unpack(h)
Out[5]: (1, 63, 192, 18, 18, 4136)

In [6]: fd.seek(4136)

In [7]: h2 = fd.read(s.size)

In [8]: s.unpack(h2)
Out[8]: (538976288, 32, 32, 32, 32, 538976288)

Can you provide more info about the test dataset?

comment:3 by antonio, 13 years ago

Just to be sure

$ md5sum CEOS2001.I3B 
f4e0533fe653cf76eff53e339015726e  CEOS2001.I3B

comment:4 by rprinceley, 13 years ago

Antonio,

This raster is part of a sample CD from Earth Remote Sensing Data Analysis Center (ERSDAC). I have examined the headers of other rasters in this dataset, they seem to be fine. We can conclude that this is a bad file as you suspect.

The fact that CEOS driver reads this file without any error or warning (even though pixels are read incorrectly) is a problem. GDAL should generate a error in this case.

comment:5 by warmerdam, 13 years ago

Keywords: SAR_CEOS added
Status: newassigned

I am digging into this. Note that the file does seem to more-or-less work with the generic CEOS driver despite what appears to be some corruption problems. I will see what I can do to have the SAR_CEOS driver skip it.

comment:6 by warmerdam, 13 years ago

Milestone: 1.8.1
Resolution: fixed
Status: assignedclosed

The problem with the file is that the record length encoded in the ceos record header does not reflect the actual offset between records in the file. This likely is due to the way that the file was created from variable length tape.

I have adjusted the SAR_CEOS driver to check the record sequence numbers (a good indicator if we are getting what we expect). If the sequence number is wrong for the second record of the imagery file we just back out of the driver quietly (with a debug message). In other places we error out.

This gives us the desired fallthrough to the regular CEOS driver. Note that the record ceos driver doesn't really work properly either - the imagery is partly corrupted because the offset to the start of imagery is a bit wrong but it is still somewhat useful.

I have applied the change in trunk (r22662) and in 1.8 branch (r22663).

Robin - I'll let you back port it to 1.8-esri or whereever else you might want it. Thanks for the report.

Note: See TracTickets for help on using tickets.