如何使用idl做GLT重投影(调用envi接口)

下面是调用envi接口来实现的GLT,效果比较好,就是稍微来说速度有点慢。(课上学的)

function get_hdf4_data,hd_name,sds_name
  hd_id=hdf_sd_start(hd_name)
  sd_id=hdf_sd_nametoindex(hd_id,sds_name)
  sds_id=hdf_sd_select(hd_id,sd_id)
  hdf_sd_getdata,sds_id,data
  hdf_sd_endaccess,sds_id
  hdf_sd_end,hd_id
  return,data
end
pro build_GLT_envi
  compile_opt idl2
  scale_factor=0.001
  dir='E:\modis_swath\'
  out_dir='E:\out\'
  out_dir1='E:\out_img\'
  file_list=file_search(dir,'*.hdf')
  print,file_list
  file_n=n_elements(file_list)
  for file_i=0,file_n-1 do begin
    name=file_list[file_i]
    need_lon_max=118
    need_lon_min=115
    need_lat_max=42
    need_lat_min=39
    AOD_data=get_hdf4_data(name,'Image_Optical_Depth_Land_And_Ocean')
    lon=get_hdf4_data(name,'Longitude')
    lat=get_hdf4_data(name,'Latitude')
    
    lat_min=min(lat)
    lat_max=max(lat)
    lon_min=min(lon)
    lon_max=max(lon)

    if ((lat_min le need_lat_min) and (lat_max ge need_lat_max)and(lon_min le need_lon_min)and(lon_max ge need_lon_max)) then begin
      lon_name=out_dir+file_basename(name,'.hdf')+'lon'+'.tiff'
      lat_name=out_dir+file_basename(name,'.hdf')+'lat'+'.tiff'
      aod_name=out_dir+file_basename(name,'.hdf')+'aod'+'.tiff'
      write_tiff,lon_name,lon,/float;open函数不能打开hdf函数,故要转换为tiff文件
      write_tiff,lat_name,lat,/float
      write_tiff,aod_name,AOD_data,/float
      envi,/restore_base_save_files
      envi_batch_init
      ENVI_OPEN_FILE,lon_name,R_FID=fid_x
      ENVI_OPEN_FILE,lat_name,R_FID=fid_y
      ENVI_OPEN_FILE,aod_name,R_FID=fid_aod
      
      i_proj=envi_proj_create(/geographic)
      o_proj=envi_proj_create(/geographic)
      envi_file_query,fid_aod,sname=sname
      out_glt_img=out_dir+sname+'_glt_'+'.img'
      out_glt_hdr=out_dir+sname+'_glt_'+'.hdr'
      pixel_size=0.03
      rotation=0.0
      x_pos=0
      y_pos=0
      pos=0
      envi_glt_doit,i_proj=i_proj,$
        o_proj=o_proj,out_name=out_glt_img,$
        pixel_size=pixel_size,r_fid=glt_fid,rotation=rotation,$
        x_fid=fid_x,y_fid=fid_y,x_pos=x_pos,$
        y_pos=y_pos;glt_fid为输出参数
        
      out_name=out_dir1+sname+'_georeproj.img'
      out_name_hdr=out_dir1+sname+'_georeproj.hdr'
      envi_doit,'envi_georef_from_glt_doit',fid=fid_aod,$
        glt_fid=glt_fid,out_name=out_name,pos=pos,$
        r_fid=r_fid;其中r_fid为输出参数,可以不管。
    endif else begin
      continue
    endelse   
  endfor
end
  • 3
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 10
    评论
评论 10
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值