ComfyUI Node

ENVI Loader

How to read the remote-sensing world's favorite format

By chenlongming·Created 2 years ago·Updated 2 years ago· 2
ENVI Loader
    • preview
    • spectral
    header_file
    image_file

    If your data is satellite or airborne remote-sensing imagery, "ENVI" is probably the word written all over it. It's the format family from Harris Geospatial's ENVI software, and it's the closest thing the field has to a universal interchange format. The ENVI Loader is the node that reads it into ComfyUI - the slightly more specialized sibling of this pack's Spectral Loader.

    Here's the shape of an ENVI dataset: a binary data file (.lan, .bil, .bsq, .bip, or extension-less) plus a plain-text .hdr sidecar that explains how to interpret it - the interleave, the data type, rows/cols/bands, even per-band wavelength information. The header is what makes the binary blob meaningful, which is why this node wants both files, separately, instead of just one path.

    How it works

    The node calls envi.open(header_file, image_file) from the spectral library, which parses the header and gives you a proper spectral image object. Then, same as the pack's other loader, it renders a preview via sp.save_rgb() to temp/envi_preview.jpg and returns the opened object as the pack's SPE type.

    The nice bit hiding in the source: a wildcard trick for lazy path entry. If image_file starts with *., the *. is replaced with the header file's basename. So type D:\data\scene.hdr as the header and *.bil as the image, and the node resolves it to D:\data\scene.bil for you. It's a small thing, but it saves you typing the data path twice when they share a name - which is the normal case.

    It also reads spectral libraries (ENVI's .sli/spectral library files), not just images. That matters if you want to compare a measured spectrum against a library of reference spectra - the loaded library feeds the same downstream nodes.

    Inputs

    • header_file (STRING) - path to the .hdr file.
    • image_file (STRING) - path to the data file, or *.<ext> to derive it from the header's basename.

    Both are plain typed strings, same as the rest of the pack - no file-browser widgets, so paste absolute paths.

    Outputs

    • preview (IMAGE) - RGB JPEG render of the cube, for PreviewImage or eyeballing.
    • spectral (SPE) - the object that feeds Calculate, Plot, and KMeans.

    Installing it

    ComfyUI Manager: search ComfyUI_Spectral, install, restart. Or manually:

    cd ComfyUI/custom_nodes
    git clone https://github.com/chenlongming/ComfyUI_Spectral
    cd ComfyUI_Spectral
    pip install -r requirements.txt
    

    then restart ComfyUI. The only new dependency you're likely missing is spectral (the README calls it reqirements.txt - misspelled, the real file is requirements.txt). No model downloads, no weights, nothing heavy.

    Where people get burned

    The classic ENVI failure mode is header and data disagreeing. The .hdr file often records where the data should be, and if that path is stale or the data lives elsewhere, you must point image_file at the right place - the explicit data path is there precisely so you can override the header. If the preview comes back wrong or the node errors on open, check that the header's byte order and interleave actually match the data; the spectral library is generally forgiving, but garbage in, garbage out.

    Also remember this is an early-stage pack - the README says functionality is incomplete and may change, and there's essentially no community presence behind it. You're on the frontier either way, so expect to debug. The good news: once spectral is installed, envi.open() behaves like it does anywhere else, so anything you know from using the library in plain Python carries over.

    CategorySpectral

    Inputs (2)

    NameTypeDefaultDescription
    header_fileSTRING
    image_fileSTRING

    Outputs (2)

    NameTypeDescription
    previewIMAGE
    spectralSPE