What format are the data files in? It's pretty easy to use one of the READ_XXXX
routines if it is in one of the image formats, so I will do the harder case that it is just a binary file. I assume you know the size (n_bands
, n_samples
, n_lines
), interleave (BIL or BIP), and data type (float below) of the image as well as the indices of the bands for NIR (nir_band
) and R (r_band
).
im = fltarr(n_samples, n_bands, n_lines) ; this is BIL
; use im = fltarr(n_bands, n_samples, n_lines) for BIP
; nir_band is an index, 0..n_bands - 1, representing near infrared light
; r_band is an index, 0..n_bands representing the visible light
nir = float(im[*, nir_band, *])
r = float(im[*, r_band, *])
ndvi = (nir - r) / (nir + r)
; you might want to use the MIN and MAX if you want to scale in a certain
; manner
byte_ndvi = bytscl(ndvi)