Hello,
I am using the below code to generate a 1-band output image. The output image lacks any coordinate and projection info.
What do I need to add to the code to have the input image geographic coordinate and projection info added to the output image?
Thank you for your help!
Here is the code:
c='E:\Hyperion_157bands\Hyperion_149bands.hdr' ;
envi_open_file, c, r_fid=fid
if (fid eq -1) then return
;Figure out the image dimensions, using the anonymous structure created with
;the query command.
envi_file_query, fid, ns=ns, nl=nl, nb=nb
NumCols = ns
NumRows = nl
NumBands = 1 ; equate the number of bands to the number of indices you will calculate.
PLS_out = fltarr(NumBands,NumCols,NumRows)
coefN = [-0.1607, -0.1658, -0.1406, -0.2482, -0.3278, -0.3606, -0.3042, -0.4071, -0.3818, -0.3257, -0.3024, -0.2538, -0.2539, -0.2181, -0.1586, -0.1068, -0.1186, -0.0016, 0.1297, 0.1872, 0.1626, 0.1545, -0.104, -0.2747, -0.4499, -0.7649, -1.9595, -2.2704, -1.8009, -0.8111, 0.0869, -0.7829, 0.4683, 0.4002, -0.3526, -0.5107, -0.0204, -0.098, -0.0156, 0.1073, -0.0882, 0.1163, -0.3109, 0.1118, -0.4181, 0.0339, -0.1352, 0.2788, 0.6463, 0.2385, 0.255, 0.4292, 0.6291, 0.0548, 0.0151, -0.0542, 0.0053, -0.1476, -0.3073, 0.0726, 0.4011, 0.2816, 0.3022, 0.4593, -0.1942, 0.3262, 0.3218, -0.5588, -0.2105, -0.2212, -0.361, 0.049, -0.1068, 0.0434, 0.0895, -0.0625, -0.1707, -0.369, -0.4028, -0.5146, -0.59, -0.392, -0.2077, -0.3629, -0.121, 0.0703, 0.1643, 0.0936, 0.341, 0.4217, 0.2116, 0.1515, 0.1567, 0.2362, 0.0863, 0.126, 0.12, 0.1489, 0.195, 0.1192, 0.2341, 0.2316, 0.0356, 0.0281, 0.0682, 0.1222, 0.0692, 0.0422, 0.0612, 0.1043, 0.1364, -0.0017, -0.0307, 0.0934, 0.068, -0.0714, -0.0704, 0.0903, 0.095, 0.2935, 0.219, -0.1959, -0.0467, -0.0128, -0.0768, 0.2079, 0.0499, 0.0387, -0.1539, -0.2703, -0.0769, 0.2971, 0.3507, -0.1497, -0.2454, -0.0831, 0.2165, -0.5471, -0.0191, -0.171, -0.1083, -0.1045, 0.2074, -0.0353, -0.0729, -0.1317, -0.0597, -0.2896, 342727.1126]
intN = -342716.2711
;x_val = intarr(149)
y_val = fltarr(149)
;loop through the image:
output=[];
for i=0, (NumCols - 1) do begin
for j=0, (NumRows - 1) do begin
y_val = envi_get_slice(fid=fid, line=j, pos=pos, xs=i, xe=i)
if (total(y_val) gt 0) then begin
out = float(total(float(y_val*coefN)) + intN);
endif
PLS_out[0,i,j] = out;
output=[output, out];
endfor
endfor
;writing the array to tiff files
e='E:\Hyperion_157bands\PLS_out2.tif'
;f=strcompress(e, /remove_all)
write_tiff, e, PLS_out, /float
;close the file and remove from envi
envi_file_mng, id=fid, /remove
end
|