Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to use GDAL to read and write images in ENVI format (for example a .bsq file with an associated .hdr file). The GDAL Formats Info page states "Starting with GDAL 1.10, all ENVI header fields will be stored in the ENVI metadata domain.". If that is the case, how should I access them?

I am using the Python bindings with GDAL 1.9.2 (the latest at this time of writing), and have tried getting all of the metadata:


which gives me a list of the band 'names' as displayed in ENVI, but that's about it. I've also tried specifically asking for the ENVI metadata domain, as instructed on the GDAL information page linked above:


but that doesn't return anything.

Is there a way to get other metadata from the ENVI file, or will I have to parse the header file myself?

Furthermore, even writing the band names (the ones that seem to be returned when I run GetMetadata()) using SetMetadata() doesn't seem to put them in the .hdr file.

Can anyone shed any light on this?

share|improve this question
up vote 5 down vote accepted

"Starting with GDAL 1.10..."

"I am using the Python bindings with GDAL 1.9.2..."

GDAL 1.10 hasn't been released yet. Beta 1 was released a short while ago or if you're using Windows, you can grab a build of the current trunk (1.10dev) from GISInternals.

If you're stuck with 1.9.2 for a while, here's some code to parse envi headers (

Some more code that uses regexes to parse a header:

import re

def get_envi_header_dict(hdr):
    #Get all "key = {val}" type matches

    #Remove them from the header

    #Get all "key = val" type matches

    return dict(matches)

if __name__=='__main__':
description = {
  RPC Orthorectification Result [Mon Aug 13 13:38:09 2012] [Mon Aug 13
  13:38:09 2012]}
samples = 27856
lines   = 30016
bands   = 1
header offset = 0
file type = ENVI Standard
data type = 12
interleave = bsq
sensor type = WorldView
byte order = 0
map info = {UTM, 1.000, 1.000, 723000.000, 8129434.000, 5.0000000000e-001, 5.0000000000e-001, 55, South, WGS-84, units=Meters}
coordinate system string = {PROJCS["UTM_Zone_55S",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",500000.0],PARAMETER["False_Northing",10000000.0],PARAMETER["Central_Meridian",147.0],PARAMETER["Scale_Factor",0.9996],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0]]}
wavelength units = Micrometers
band names = {
 Orthorectified (Band 1)}
wavelength = {
    print get_envi_header_dict(hdr)
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.