Skip to content

Error when opening ENVI datasets

Cédric Traizet requested to merge bug_opening_envi_dataset into release-7.1

Summary

Reading a ENVI dataset with ImageFileReader result in the following error :

ERROR 1: The selected file is an ENVI header file, but to open ENVI datasets, the data file should be selected instead of the .hdr file. Please try again selecting the data file corresponding to the header file: CupriteAVIRISSubset.hdr

even is the file is successfully opened.

Analysis

When reading the input image (in ImageFileReader::GenerateOutputInformation), there is different ways to read the geometric information and build the otb::ImageKeywordList, by order of priority :

  1. don't read anything if the extended filename &skipgeom is set to true
  2. Try to read an external geom file provided by the extended filename &geom
  3. Try to read an external geom file attached to the input image (inputfilename.geom)
  4. Try to read it from the input image using ossimPluginProjection
  5. Try to read it from the input image using ossimProjection
  6. Try to read it from the input image using gdal rcp tags.

Then for each attached file

  1. try to read it from the attached file using ossimPluginProjection
  2. Try to read it from the input image using ossimProjection
  3. Try to read it from the input image using gdal rcp tags.

The "attached file" are a list of files associated with the input filename, given by the gdal driver used to open the input image, in this case the ENVI driver. For the ENVI driver the attached files are the header and eventually the stat file.

In the case of the input data considered in this issue, there is no geom information attached, and no rpc in the envi dataset, so all 9 cases are tested and don't return anything. In particular steps 7 8 and 9 are applied to the .hdr file.

In particular in case 9 OTB tries to read the .hdr file as a GDAL dataset. GDALIdentifyDriver(...) is used. This method tries to find a driver able to open the file in the list of available gdal drivers. To do so for each driver the Identify() method of the driver is called, and if this method is not implemented (which is the case for the ENVI driver) the driver tries to open the file. So at some point the ENVI driver tries to open the .hdr file, resulting in this error. The driver the return a null dataset, step 9 does not return anything, no keyword list is built and the application continue.

So this error message is just noise. But it is a bit confusing, so it would be nice to be able to remove it ...

It is important to note that if there were RCPs in the ENVI dataset they would be read by GDAL in step 6, not 9 (even if the information is stored in the .hdr)

closes #1995

solution

Don't try to open the hdr file in ossimKeywordList

Copyright

The copyright owner is CNES and has signed the ORFEO ToolBox Contributor License Agreement.


Check before merging:

  • All discussions are resolved
  • At least 2 👍 votes from core developers, no 👎 vote.
  • The feature branch is (reasonably) up-to-date with the base branch
  • Dashboard is green
  • Copyright owner has signed the ORFEO ToolBox Contributor License Agreement
  • Optionally, run git diff develop... -U0 --no-color | clang-format-diff.py -p1 -i on latest changes and commit
Edited by Cédric Traizet

Merge request reports