;*Usage:根据参考对照txt文件对栅格数据进行重新编码 ;参考文件---Ref_file ;参考文件中的line数目---line_num ;栅格文件---LC_img(为envi standard file) ;输出文件---outfile pro LCLU_ID_Transform,ref_file,line_num,LC_img,outfile temp=' ' ;*get the "Ref-file" in openr,lun1,ref_file,/get_lun ;jump the first line readf,lun1,temp LC_ID=intarr(line_num) SYS_ID=intarr(line_num) for i=1,line_num do begin readf,lun1,temp records=strsplit(temp,string(9B),/extract) LC_ID(i-1)=fix(records[0]) SYS_ID(i-1)=fix(records[1]) endfor close,lun1 free_lun,lun1 ;*get the LC_img_arcgis in envi_open_file,r_fid=fid,LC_img if fid eq -1 then begin message,'Cannot open file '+LC_img endif envi_file_query,fid,ns=ns,nl=nl,nb=nb,data_type=d_type dims=[-1,0,ns-1,0,nl-1] img=bytarr(ns,nl) img1=bytarr(ns,nl) img=envi_get_data(fid=fid,dims=dims,pos=0) ;*process the lCLU data map for i=1,line_num do begin index=where(img eq SYS_ID(i-1),count) if count gt 0 then begin img1[index]=LC_ID(i-1) endif endfor ;*output the image openw,lun,outfile,/get_lun writeu,lun,img1 free_lun,lun close,lun map_info=envi_get_map_info(fid=fid) envi_setup_head, fname=outfile, ns=ns, nl=nl, nb=1, $ data_type=d_type, interleave=0, map_info=map_info, /write, $ descrip='LCLU Map' end