[gdal-dev] Error writing/reading simple ENVI file

jratike80 jukka.rahkonen at maanmittauslaitos.fi
Thu Sep 10 23:16:22 PDT 2020


Calogero Mauceri wrote
> 
> I'm not sure why it tries to open the ENVI file using the OpenJPEG reader.
> Anyway I'm using GDAL 2.4.4 and OpenJPEG 2.3.0. I tried GDAL 3.1.2, but I
> get the same error.

GDAL is quessing the driver by the file name extension and starts trying
them one by one, in the order they appear in the list of supported drivers.
ENVI files are often named as .bsq, .bip, or .bil and then the guess is
usually right. However, .IMG is used by several other drivers as well.

The JP2OpenJPEG driver may be too eager to open images with any name
extension. I modified your command a bit into 

gdal_translate -of ENVI test.tiff test.png

and the gdalinfo error comes from OpenJPEG also in this case

OPENJPEG: info: Start to read j2k main header (0).
ERROR 1: A marker ID was expected (0xff--) instead of 000028fc

ERROR 1: opj_read_header() failed
gdalinfo failed - unable to open 'test.png'.

GDAL 3.2 is introducing a new option -if that stands for "input format". Now
user fo not need to find out what all drivers must be skipped.

gdalinfo -if envi test.png
Driver: ENVI/ENVI .hdr Labelled
Files: test.png
       test.hdr


-Jukka Rahkonen-




--
Sent from: http://osgeo-org.1560.x6.nabble.com/GDAL-Dev-f3742093.html


More information about the gdal-dev mailing list