Skip to content

Can not write in hdr file format with positive y spacing starting gdal 2.2.0

Description

Gdal does not support writing of ENVI file format files with positive y spacing (see https://github.com/OSGeo/gdal/issues/944 ). This has always been the case, but is now highlighted by the introduction of rotated dataset support in gdal >= 2.2.0. As a result, gdal fails to read back properly HDR file with positive y spacing, which result in breaking 61 tests in OTB, for instance:

https://dash.orfeo-toolbox.org/testDetails.php?test=87403756&build=336449

Steps to reproduce

$ CPL_DEBUG=ON otbcli_Convert -in otb-data/Input/phr_pan.tif -out test.hdr
ENVI: rot1 = 0, rot2 = 180
Warning 1: Geotransform matrix has non rotational terms

$ ./bin/otbcli_ReadImageInfo -in otb-data/Input/phr_pan.tif
[...]
        Spacing :  [1,1]
[...]

$ ./bin/otbcli_ReadImageInfo -in test.hdr
[...]
        Spacing :  [6.12323e-17,-6.12323e-17]
[...]

Possible fix

  • Replace all baselines in envi format by tif format
  • In GdalImageIO, warn if someone tries to write in envi format with a positive y spacing.