Fork me on GitHub

GDAL ENVI Rotation Bug Fix

Posted 2017-04-30 by Taylor Alexander Brown

COAL is a library for processing imaging spectrometer data from AVIRIS and AVIRIS-NG. The multiband raster imagery is provided in ENVI format. COAL uses the Geospatial Data Abstraction Library (GDAL) and the Free and Open Source geographic information system QGIS to process imagery and combine it with geographic data for analysis. Due to a bug in GDAL, rotation information in ENVI files was not handled and the images were not imported correctly. This post describes a bug fix which was developed for COAL and contributed back to GDAL.

Incorrectly rotated flightline
Figure 1: Incorrectly rotated flightline.
Correctly rotated flightline
Figure 2: Correctly rotated flightline.

The rotation issue was first discussed on our mailing list after loading the imagery into GIS applications. The same behavior was observed in QGIS, GRASS, and ArcMap, all of which use the underlying GDAL library. To help solve the problem, a question was posted to the GIS StackExchange describing the issue and requesting assistance. The proposed answer did not work, suggesting it was due to a bug in the ENVI driver of the GDAL library itself.

It was found that the ENVI rotation parameter, which is not documented in the header file format, was ignored by GDAL when reading the geographic transformation information. As a result, images were imported incorrectly by all software using GDAL, including the Python interface, command-line utilities, and GIS applications. The problem affected the GDAL source file gdal/frmts/raw/envidataset.cpp. Editing this file with the values suggested by the StackExchange answer solved the issue, allowing images to be rotated correctly.

The solution was shared on the GDAL mailing list where it received feedback from the GDAL developers. After addressing the changes requested by the maintainers, a pull request was submitted. The maintainer added write support to the patch and merged it into the latest version of the library scheduled for release on 2017-05-01 as part of GDAL 2.2.0.

The resolution of this bug facilitated continued progress in COAL for processing and visualizing georeferenced raster imagery. It also provided experience contributing to another Free and Open Source Software library. Once the latest version of GDAL is released, QGIS and other applications will have enhanced capabilities for reading and writing ENVI files from AVIRIS, AVIRIS-NG, and other remote-sensing devices.

Next: Expo Poster