MCTK批处理MODIS 09A1产品

MCTK批处理MODIS 09A1产品

ENVI+IDL版本:5.3
MCTK版本:V2.1.11

MCTK的下载与安装

下载地址 :https://github.com/dawhite/MCTK/releases
简介及安装详见_yaohuizheng671的博客-CSDN博客
MCTK实现MODIS数据坐标重投影 https://blog.csdn.net/yaohuizheng671/article/details/105089873MCTK批处理MODIS 09A1产品_第1张图片
将MODIS09A1数据导入MCTK,左边大方框里有数据相关信息。中间方框显示包含的波段内容,右侧选择投影。
本人是编程小白,花了一个星期,参考前辈们的文章,才折腾出以下批处理代码,运行成功,和大家分享一下。

pro test_batch_modis_conversion_grid
  compile_opt idl2
  e = envi()
  envi, /restore_base_save_files
  envi_batch_init, log_file='batch.txt'

  ;选择需要批处理文件所在的文件夹
  inpath = 'E:\EarthDATA\TEST\'
  cd, inpath
  filenames = file_search('*.hdf')
  n = N_elements(filenames)
  print, n
  
  PRINT, '开始处理数据 : ', SYSTIME()
  ;导出
  
  bridges = mctk_create_bridges()
  FOR i = 0, n-1  DO BEGIN
    modis_grid_file = inpath+filenames[i]

    filename = filenames[i]

    print,filename
    
    ;选择处理后文件另存的文件夹位置
    outpath = 'E:\EarthDATA\TEST_output\'
    ;提取原文件前23位作为处理后文件的名称
    output_rootname = STRMID(filename, 0, 23)
    ;数据集或格网名称,不同数据名称在MCTK窗口中导入数据可看到
    grid_name = 'MOD_Grid_500m_Surface_Reflectance'
    ;选择要处理的波段
    sd_names = ['sur_refl_b01','sur_refl_b02','sur_refl_b03']
    ;Output method schema is:
    ;0 = Standard, 1 = Reprojected, 2 = Standard and reprojected
    out_method = 1
    ;选择地理坐标系统,这些是指导手册案例的内容
    output_projection = ENVI_PROJ_CREATE(/geographic)
    ;OPTIONALLY specify the output X and Y pixel sizes in double precision floating
    ;point. Sizes must be in units relevant to selected output projection
    ;(degrees in this example).
    out_ps = [0.004187d,0.004187d]

    ;Choosing cubic convolution interpolation.
    interpolation_method = 0

    ;Set reprojection background and any native fill values to NaN
    nan_fill = float('NaN')
    ;以下是调用mctkh函数
    convert_modis_data, in_file=modis_grid_file, $
      out_path=outpath, out_root=output_rootname, $
      gd_name=grid_name, sd_names=sd_names, $
      out_method=out_method, out_proj=output_projection, $
      out_ps=out_ps, interp_method=interpolation_method, $
      background=nan_fill, fill_replace_value=nan_fill, $
      r_fid_array=r_fid_array, r_fname_array=r_fname_array, $
      msg=msg 
    print,output_rootname
  ENDFOR
  mctk_destroy_bridges, bridges
  PRINT, '处理完成 : ', SYSTIME()
  envi_batch_exit

end

导入的数据:
MOD09A1.A2020001.h27v05.006.2020010222314.hdf
MOD09A1.A2020009.h27v05.006.2020018040552.hdf
输出的数据:
在这里插入图片描述
在ENVI中打开
MCTK批处理MODIS 09A1产品_第2张图片
参考资料
【1】MCTK批处理MODIS L2 swath产品:https://blog.csdn.net/tk20190411/article/details/105388871
【2】MCTK用户手册

你可能感兴趣的:(MCTK批处理MODIS 09A1产品)