pro dattotif_1;将dat文件批量转换为tif格式
envi = ENVI()
dat_dir = 'F:\MOD02 1KM\2019\1_month\MOD021KM.A2019031.0430.061.2019036170900\'
tif_dir = 'F:\MOD02 1KM\2019\1_month\test\'
file=file_search(dat_dir,'*dat',count = num) ;dat文件个数存储到变量num中
for i=0, num-1 do begin ;遍历所有dat文件
raster = envi.OpenRaster(file[i])
dat_filename = strsplit(file[i], '\' ,/EXTRACT)
dat_filename = dat_filename[-1]
dat_filename = strsplit(dat_filename,/EXTRACT)
dat_filename = dat_filename[0]
tif_filename = dat_filename + '.tif'
tif_path = tif_dir + tif_filename
raster.Export, tif_path, 'TIFF'
endfor ;结束for循环
print,'Process Over'
end