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

Even Rouault even.rouault at spatialys.com
Fri Sep 11 02:58:37 PDT 2020


On jeudi 10 septembre 2020 23:16:22 CEST jratike80 wrote:
> 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.

Actually most GDAL drivers avoid as much as possible relying on extensions, but rather on 
'signatures' in file content. Of course with the ENVI driver where the filename passed for 
opening is the one of the raw raster content, there's no such signature, and thus this driver is 
tried after all other content-based drivers, because it has to detect the .hdr sidecar file as 
well. 
> 
> The JP2OpenJPEG driver may be too eager to open images with any name
> extension. I modified your command a bit into

The issue was actually true of several JPEG2000 capable drivers that can open a raw 
JPEG2000 codestream, and identified it with the first 2 bytes only. But actually the first 4 
bytes are fixed, so in
https://github.com/OSGeo/gdal/pull/2931 I detect them, which should considerably reduce 
the likelihood of false identification

Even

-- 
Doing Open Source mostly as a greedy capitalist,
as a hobbyist by accident at times.
Spatialys - Geospatial professional services
http://www.spatialys.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20200911/ddcb5e1e/attachment.html>


More information about the gdal-dev mailing list