Opened 8 years ago

Closed 8 years ago

#3123 closed defect (fixed)

Failure to load new Surfer Grid Format

Reported by: whatnick Owned by: warmerdam
Priority: normal Milestone:
Component: GDAL_Raster Version: 1.5.4
Severity: normal Keywords: GS7BG
Cc: adam@…

Description

Surfer Demo 9.x saves .grd files which fail to be read due to "version mismatch"

Attachments (1)

merged_ndvi.grd (59.5 KB) - added by whatnick 8 years ago.
Surfer Grid

Download all attachments as: .zip

Change History (6)

Changed 8 years ago by whatnick

Attachment: merged_ndvi.grd added

Surfer Grid

comment:1 Changed 8 years ago by warmerdam

Cc: adam@… added
Component: defaultGDAL_Raster
Keywords: GS7BG added
Status: newassigned

The file is recognised by the GS7BG (Golden Surfer 7 Binary Grid) driver but it has a major version of 2 instead of 1 in the file so the reading fails. I have found I can comment out this section of code:

    if(nVersion != 1)
    {
        delete poDS;
        CPLError( CE_Failure, CPLE_FileIO, "Incorrect file version.\n" );
        return NULL;
    }

and then file access appears to work, but it is unclear to me what the risks are to removing this check.

I'm adding Adam Guernsey who originally implemented the driver as a cc: in case he has any opinion on how to proceed.

comment:2 in reply to:  1 ; Changed 8 years ago by whatnick

Replying to warmerdam:

The file is recognised by the GS7BG (Golden Surfer 7 Binary Grid) driver but it has a major version of 2 instead of 1 in the file so the reading fails. I have found I can comment out this section of code:

    if(nVersion != 1)
    {
        delete poDS;
        CPLError( CE_Failure, CPLE_FileIO, "Incorrect file version.\n" );
        return NULL;
    }

and then file access appears to work, but it is unclear to me what the risks are to removing this check.

I'm adding Adam Guernsey who originally implemented the driver as a cc: in case he has any opinion on how to proceed.

Where is the said version 2 - can I fiddle it by hand and use the file ?

comment:3 in reply to:  2 Changed 8 years ago by whatnick

Ok used a hex editor to change the 8th byte from 02 to 01 and now all is peachy ... may be the check should accept 01 and 02.

comment:4 Changed 8 years ago by adam

Looking at file format details from the latest Demo version of Surfer (9.5.510) it appears the only difference between the two versions is the following change:

If the version field is 1, then any value >= BlankValue? will be blanked using Surfer’s blanking value, 1.70141e+038.

If the version field is 2, then any value == BlankValue? will be blanked using Surfer’s blanking value, 1.70141e+038.

So it seems just allowing version 2 is not the only change needed.

comment:5 Changed 8 years ago by warmerdam

Resolution: fixed
Status: assignedclosed

Ok, sounds good. I have modified the code allow version 1 or 2 in trunk (r17605) and 1.6 branch (r17606).

Note: See TracTickets for help on using tickets.