Add metadata

Add metadata

posted 02-27-2003 02:48 AM
I’ve a script which imports image data from a HDF5 file as a IDL variabele in ENVI and loads it into the avialable bands list in ENVI. But the HDF5 file also contains georeference metadata which i would like to include when importing the image data. This metadata contains 1 row and 41340 columns. First the image xpixel and ypixel are on the first 2 columns followed in the next 2 columns by the corresponding lon/lat. Then it shifts 33 pixels to the right and so on.At the end of 1 scanline (2048 pixels) it shifts 33 lines down.
Now I can import the metadata and load it into the available band list, but I want to link it with the image data.
Here follows part of the script for importing the image data or metadata and loading into available band list:

; Import variable into the ENVI !!!!!!!!!
; No need to use the Routine_Names part here
; as we are using the data directly
;dummy = ROUTINE_NAMES(name, STORE=0, sSelect)
;MESSAGE, /INFO, /NONAME, ‘Imported variable: ‘+ name
good = sSelect._TYPE EQ “DATASET”
if good then begin
;; If there is a non-black and white palette
;; associated with a single byte image, make an RGB image
;; from the image to reflect the colors in ENVI

;; Get the palette
;; Make sure the preview is updated
h5_browser_tree_preview, state, sSelect

tvlct, red, green, blue, /get
lut = transpose([[red],[green],[blue]])
;; Reload the black & white color table so ENVI displays correctly
loadct, 0, /silent
ramp = bindgen(256)
;;; If it is a black-white ramp leave it
bw = ARRAY_EQUAL(red, ramp) AND ARRAY_EQUAL(green, ramp) AND ARRAY_EQUAL(blue, ramp)

if (size(sSelect._data, /N_Dimensions) eq 2) AND $
(sSelect._storagesize eq 1) AND (bw EQ 0) then begin

s = size(sSelect._data, /dimension)
data = Rebin(sSelect._data, s[0], s[1], 3)

for band = 0, 2 do begin

slice = data[*,*, band]
;hmin = min(slice, max=hmax)


; Set all elements of A that are in the ith bin of H
; equal to the value in the color palette (LUT)
for i = 0, 255 do begin
IF R[i] NE R[i+1] THEN slice[R[R[I] : R[i+1]-1]] = lut[band, i]

data[*,*, band] = slice


bandnames = [‘R:’+sSelect._Name, ‘G:’+sSelect._Name, ‘B:’+sSelect._Name]

dmin = min(data, max=dmax)
def_stretch = envi_default_stretch_create(/linear, val1=dmin, val2=dmax)

endif else begin
data = sSelect._data
bandnames = sSelect._Name
dmin = min(data, max=dmax)
def_stretch = envi_default_stretch_create(/linear, val1=0, val2=255)
envi_enter_data, data, $
BNames = bandnames, $
Descrip = sSelect._FILE, $
Def_Stretch = def_stretch
; ‘, File_type = 3 ‘ + $
; ‘, Lookup = lut’
endif else begin
type = sSelect._TYPE
ok = dialog_message([‘Not able to import ‘+name[0], $
‘because ENVI cannot display data of type ‘ + type])


Geo Newbie

Leave a Reply