IDL恢复全球分类

  Compile_opt idl2
   ENVI,/restore_base_save_files
   ENVI_BATCH_INIT
   workdir=SourceRoot()
   
   lcc_file = workdir+'\'+'lcc_global_5km.img'
   ;**1. read img data
   ENVI_OPEN_DATA_FILE, lcc_file, r_fid = fid, /ENVI
   ENVI_FILE_QUERY, fid, dims = dims, ns = ns, nl = nl
   lcc_data = ENVI_GET_DATA(fid = fid, dims = dims, POS=0)
   
   dims0=size(lcc_data, /DIMENSIONS)
   ;**2. imgshow img data
;    window, 0, xsize = dims0[0], ysize = dims0[1], $  
;    TITLE = 'Image'   ;定义显示窗口,和数据同样大的窗叄1�7    
;    TV, lcc_data
   
   
   ;颜色转换部分自己补充
   outdata=intarr(dims0[0],dims0[1],3)
;    outdata[*,*,0] = ??
;    outdata[*,*,1] = ??
;    outdata[*,*,2] = ??  
for i=0,dims0[0]-1 do begin
 for j=0,dims0[1]-1 do begin

   case lcc_data[i,j,0] of
     0:begin outdata[i,j,0]=23
       outdata[i,j,1]=23
       outdata[i,j,2]=115
       end
     1:begin outdata[i,j,0]=33
       outdata[i,j,1]=138
       outdata[i,j,2]=33
       end
     2:begin outdata[i,j,0] =49
       outdata[i,j,1] =205
       outdata[i,j,2] =49
       end
     3:begin outdata[i,j,0] =154
       outdata[i,j,1] =205
       outdata[i,j,2] =49
       end
     4:begin outdata[i,j,0] =151
       outdata[i,j,1] =250
       outdata[i,j,2] =151
       end
     5:begin outdata[i,j,0] =143
       outdata[i,j,1] =187
       outdata[i,j,2] =143
       end
     6:begin outdata[i,j,0] =187
       outdata[i,j,1] =143
       outdata[i,j,2] =143
       end
     7:begin outdata[i,j,0] =245
       outdata[i,j,1] =222
       outdata[i,j,2] =179
       end
     8:begin outdata[i,j,0] =219
       outdata[i,j,1] =235
       outdata[i,j,2] =157
       end
     9:begin outdata[i,j,0] =255
       outdata[i,j,1] =214
       outdata[i,j,2] =0
       end
     10:begin outdata[i,j,0] =239
       outdata[i,j,1] =183
       outdata[i,j,2] =102
       end
     11:begin outdata[i,j,0] =70
       outdata[i,j,1] =130
       outdata[i,j,2] =178
       end
     12:begin outdata[i,j,0] =250
       outdata[i,j,1] =237
       outdata[i,j,2] =115
       end
     13:begin outdata[i,j,0] =255
       outdata[i,j,1] =0
       outdata[i,j,2] =0
       end
     14:begin outdata[i,j,0] =153
       outdata[i,j,1] =147
       outdata[i,j,2] =85
       end
     15:begin outdata[i,j,0] =255
       outdata[i,j,1] =249
       outdata[i,j,2] =249
       end
     16:begin outdata[i,j,0] =189
       outdata[i,j,1] =189
       outdata[i,j,2] =189
       end
     else:outdata[i,j,0] =0
   endcase

 endfor
endfor
       
       
   ;**4. write data to envi img data
 
   outname = workdir+'\'+ 'lcc_color.img'
   

   bnames=['lcc_r','lcc_g','lcc_b']
       
   POS0 = indgen(3)
     
   Envi_enter_data, outdata, r_fid=out_fid;, map_info = map_info  
   ENVI_FILE_QUERY, out_fid, dims=dimso ;, ns=ns, nl=nl, nb=nb
   Envi_output_to_external_format, fid=out_fid, out_name = outname, $
                       out_bname=bnames, dims=dimso, pos=POS0, /envi
       
   print,'end pro'

End

; subroutines
; Function for retrieval wordir
;
Function SourceRoot

 COMPILE_OPT HIDDEN, STRICTARR
 On_Error, 2
 Help, Calls = Calls
 UpperRoutine = (StrTok(Calls[1], ' ', /Extract))[0]
 Skip = 0

 Catch, ErrorNumber

 If (ErrorNumber ne 0) then Begin
   Catch, /Cancel
   Message, /Reset
   ThisRoutine = Routine_Info(UpperRoutine, /Functions, /Source)
   Skip = 1
 EndIf

 If (Skip eq 0) then Begin
   ThisRoutine = Routine_Info(UpperRoutine, /Source)
   If (ThisRoutine.Path eq '') then Begin
     Message, '', /Traceback
   EndIf
 EndIf

 Catch, /Cancel

 If (StrPos(ThisRoutine.Path, Path_Sep()) eq -1) then Begin
   CD, Current = Current
   SourcePath = FilePath(ThisRoutine.Path, Root = Current)
   EndIf Else Begin
   SourcePath = ThisRoutine.Path
 EndElse

 Root = StrMid(SourcePath, 0, StrPos(SourcePath, Path_Sep(), /Reverse_Search) + 1)
 Return, Root

 

  • 3
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值