How to use envi setup head function?

322 Views Asked by At

I don't understand the envi_setup_head. Could anyone help me write it in IDL code format?

I have maps that were produced in IDL and I need to process them in ENVI. I don't know how to save the images in a folder and be able open them in ENVI. Does anyone know how to do it?

1

There are 1 best solutions below

0
On

To create an ENVI header for an image file, you can try something like the IDL procedure below. It creates a small image file and uses envi_setup_head to create an ENVI header file. Essentially all you have to do is provide it with the number of samples, lines, data-type, etc., and you are good to go.

pro enviHeaderTest
    compile_opt idl2

    ; Create the data and write to a file.
    ns = 100
    nl = 100
    data = dist(ns, nl)
    fname = 'mydatafile.dat'
    openw, lun, fname, /GET_LUN
    writeu, lun, data
    close, lun

    ; Open a headless ENVI.
    nv = envi(/HEADLESS)

    ; Create some map info for the raster.
    mc = [0,0,0,0] ;Tie point: [x pixel, ypixel, x map, y map]
    ps = [1D/3600, 1D/3600] ; Pixel size
    mapInfo = envi_map_info_create(/GEOGRAPHIC, MC=mc, PS=ps)

    ; Create the header.
    envi_setup_head, FNAME=fname, $ ; file name
        NS=ns, $                    ; number of samples
        NL=nl, $                    ; number of lines
        NB=1, $                     ; number of bands
        DATA_TYPE=4, $              ; IDL data type (float in this case)
        INTERLEAVE=0, $             ; BSQ
        MAP_INFO=mapInfo, $
        /WRITE

    ; Close ENVI.
    nv.close
end

Then, you can read the image into ENVI, either from the File->Open menu, or via the IDL command line like so:

IDL> nv = envi()
ENVI> view = nv.getview()
ENVI> raster = nv.openraster('mydatafile.dat')
ENVI> layer = view.createlayer(raster)