Skip to content

case sensitivity of keys in ENVI header files #30

@donm

Description

@donm

Although it appears to be undocumented, ENVI treats keys in header files as case insensitive. Some data creators are assuming the behavior and their .hdr files look like this

ENVI 
SAMPLES = 160
LINES = 640
...

instead of this

ENVI 
samples = 160
lines = 640
...

This causes problems for mandatory keywords, checked in spectral/io/envi.py around line 737

    # Verify minimal set of parameters have been provided
    if 'lines' not in metadata:
        raise Exception('Number of image rows is not defined.')
    ...

What do you think is the best way of dealing with this? Some possibilities:

  1. Apply .lower() to all keywords in ENVI headers. (easy: envi.py line 115)
  2. Apply .lower() only to mandatory keywords in ENVI headers (lines, samples, bands, etc.) (personally not a fan of this option).
  3. Optional case_insensitive keyword argument. Probably has to be added to read_envi_header(), open() and gen_params() in envi.py, and possibly to open_image() in spectral.py.

Or maybe something better that I'm not thinking of. Let me know what you think and if you'd like me to submit a pull request.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions