Opened 11 years ago

Closed 11 years ago

#3305 closed defect (wontfix)

Cannot open file in SRTMHGT format

Reported by: hansm Owned by: warmerdam
Priority: normal Milestone:
Component: GDAL_Raster Version: 1.6.2
Severity: normal Keywords: jpeg srtmhgt


When trying to read a file in SRTM3 .hgt format, I get the following error message:

ERROR 1: libjpeg: Invalid JPEG file structure: two SOI markers

GDALOpen failed - 1

libjpeg: Invalid JPEG file structure: two SOI markers

This seems to be a problem with the SRTMHGT driver as the error occures in various command line tools, e.g. gdal_translate, as well as in my C++ application program.

As far as I see, there are not too many ways for a .hgt file to be malformed. The number of bytes is correct. My .hgt file is not the orgininal as shipped by SRTM3, but a modification.

I send you the problematic .hgt file as attachment.

Attachments (1)

N53E005.hgt.bz2 (72.1 KB) - added by hansm 11 years ago.
problematic .hgt file

Download all attachments as: .zip

Change History (2)

Changed 11 years ago by hansm

Attachment: N53E005.hgt.bz2 added

problematic .hgt file

comment:1 Changed 11 years ago by warmerdam

Keywords: jpeg srtmhgt added
Resolution: wontfix
Status: newclosed

Unfortunately the file starts with the byte sequence 0xffd8ff and this is the code we look for to identify a file as a JPEG file. I notice the linux "file" command also mis-recognises this files as jpeg.

As a workaround you can define the GDAL_SKIP environment variable to JPEG to temporarily disable the JPEG driver and then it works properly as an SRTMHGT file.

At a point in the past we had a more involved jpeg recognition system but it was fragile, and we kept running into very simple jpeg files that it did not recognize. So at that point I fellback to the current jpeg recognition code.

I'm aware false positives are a possibility but I am hesitant to make any dramatic changes for this rare occurrence.

Note: See TracTickets for help on using tickets.