IDL处理MODIS 地表温度数据(MOD11A2)最大值法

8天数据使用最大值法合成年数据

以下代码为转载IDL大神成果,表示敬意!

pro max_value

  COMPILE_OPT IDL2
  ENVI, /RESTORE_BASE_SAVE_FILES
  ENVI_BATCH_INIT, /NO_STATUS_WINDOW

  file_dir = 'G:\modis\lst2015\'
  file_dir = FILE_SEARCH(file_dir,'*..LST_*_1km.tif', /MARK_DIRECTORY,  count = num_file)
  file_out = 'G:\modis\lst2016\LST2015.tif'
  
  ENVI_OPEN_FILE, file_dir[0], r_fid = fid
  file_idir = FILE_SEARCH(file_dir[0])
  RASTER_INFO, file_idir, fid, nb, ns, nl, dims, data_type, $
    interleave, map_info, flag
  data1 = READ_TIFF(file_idir, GEOTIFF = geotiff)
  
  FOR i = 1L, num_file-1 DO BEGIN
    ENVI_OPEN_FILE, file_dir[i], r_fid = fid
    file_idir = FILE_SEARCH(file_dir[i])  
    RASTER_INFO, file_idir, fid, nb, ns, nl, dims, data_type, $
      interleave, map_info, flag
    data = READ_TIFF(file_idir, GEOTIFF = geotiff)
    FOR j = 0L, ns-1 DO BEGIN
      FOR k = 0L, nl-1 DO BEGIN
        data1[j,k] = MAX([data[j,k], data1[j,k]])
      ENDFOR
    ENDFOR

    print,i
    
  ENDFOR

  WRITE_TIFF, file_out, data1*0.1, GEOTIFF = geotiff, /FLOAT
  
END

PRO RASTER_INFO, path_InputRaster, fid, nb, ns, nl, dims, data_type, $
  interleave, map_info, flag

  COMPILE_OPT IDL2
  ENVI, /RESTORE_BASE_SAVE_FILES
  ENVI_BATCH_INIT, /NO_STATUS_WINDOW

  ENVI_OPEN_FILE, path_inputRaster, R_FID = fid, /NO_INTERACTIVE_QUERY, /INVISIBLE
  IF (fid EQ -1) THEN BEGIN
    r_dia = DIALOG_MESSAGE('դ����ݴ��?',$
      /CENTER, TITLE = '����', /ERROR)
    flag = 0
    RETURN
  ENDIF

  ENVI_FILE_QUERY, fid, NB = nb, NS = ns, NL = nl, DIMS = dims, $
    DATA_TYPE = data_type, INTERLEAVE = interleave

  map_info = ENVI_GET_MAP_INFO(FID = fid, UNDEFINED = undefined)
  IF (undefined eq 1) THEN BEGIN
    r_dia = DIALOG_MESSAGE('ͶӰ��ʽ����', $
      /CENTER, TITLE = '����', /ERROR)
    flag = 0
    ;    RETURN
  ENDIF

END

PRO Basename, InputFilePath, basename, filetype

  COMPILE_OPT IDL2

  fullname = FILE_BASENAME(InputFilePath)
  subname = STRSPLIT(fullname, '.', /EXTRACT)
  n_subname = N_ELEMENTS(subname)
  IF n_subname EQ 1 THEN BEGIN
    basename = subname[0]
  ENDIF ELSE BEGIN
    basename = ''
    filetype = ''
    IF n_subname GT 2 THEN BEGIN
      For i = 0, n_subname-2 DO BEGIN
        IF i EQ 0 THEN BEGIN
          basename = basename + subname[i]
        ENDIF ELSE BEGIN
          basename = basename +'.'+ subname[i]
        ENDELSE
      ENDFOR
      filetype = subname[n_subname-1]
    ENDIF ELSE BEGIN
      basename = subname[0]
      filetype = subname[1]
    ENDELSE
  ENDELSE

END

你可能感兴趣的:(IDL处理MODIS 地表温度数据(MOD11A2)最大值法)