IDL实现MOD021KM 角度数据重采样中的易错点

最近很忙,每天都特别忙碌,也很少有时间去打球了。

祝愿大家一切都好,北京一切还好,就是北京物价很贵,没有工资补助的我露出了卑微的笑容~

今天和大家分享的是IDL怎么读取MOD021KM MYD021KM中的角度数据,将其重采样到其他的反射率光谱数据的维数大小,即ns = 1354,nl = 2030.重要的是如何避免最容易错的地方,直接po上程序来,如下:
本来我是批处理的,此处简化,po出单景图像的程序,亦可用(中间的其他经纬度代码是我原来读取的时候要用到的,没有用但我就不删除了)。

pro MODIS_angle_resize
  ;***************************启动ENVI批处理模式************************************
  time_begin = systime(1)
  compile_opt idl2
  envi,/restore_base_save_files
  envi_batch_init
  cd,'G:\MODIS_TOA_r_Original\'
  fnames = 'MOD021KM.A2018071.0240.061.2018071132914.hdf'
  out = modis_georef(fnames)
  envi_batch_init
  time_end = systime(1)
  print,'running time :',(time_end-time_begin)/60.0,'mins'
end
;***************************所调用的函数*********************************************
function modis_georef,fn
  ;在函数中也一定要加上编译,否则主过程中的compile不会传到函数中
  compile_opt idl2
  envi,/restore_base_save_files;打开文件
  hd_id = hdf_sd_start(fn)
  ;读取文件数据集数量和属性数量
  hdf_sd_fileinfo,hd_id,nsds,natts
  ;选择打开数据集
  lat_id = hdf_sd_select(hd_id,0)
  long_id = hdf_sd_select(hd_id,1)
  SOZ_id = hdf_sd_select(hd_id,16)
  ;*****************************************读取经纬度数据值*********************************************
  hdf_sd_getdata,lat_id,Lat
  hdf_sd_getdata,long_id,Lon
  hdf_sd_getdata,SOZ_id,SOZ
  SOZ = SOZ*0.01
  ;*****************************************SOZ角度重采样**********************************************
  sz = size(SOZ)
  ns0 = sz[1]
  nl0 = sz[2]
  ;print,angle[58:60,69:71,3]
  envi_enter_data,SOZ,r_fid = SOZ_fid,ns = ns0,nl = nl0,nb= 1,data_type = 4,interleave = 0,offset = 0
  pos = lindgen(1)
  dims = [-1,0,ns0-1,0,nl0-1]
  outname = 'G:\MODIS_TOA_反射率\out1'
  xsize = ns0/1354.0
  ysize = nl0/2030.0
  envi_doit,'resize_doit',fid = SOZ_fid,dims = dims,pos = pos,interp = 1,rfact = [xsize, ysize],out_name =outname ,r_fid = r_fid
  ;关闭数据集
  hdf_sd_endaccess,lat_id
  hdf_sd_endaccess,long_id
  hdf_sd_endaccess,SOZ_id
  hdf_sd_end,hd_id;关闭文件
end

易错点1:
xsize = ns0/1354.0
ysize = nl0/2030.0
重采样的时候设置的xsize和ysize必须是由原来的小size的图像行列数比上最终要得到的重采样后的图像行列号(本程序中是采样到对应的文件中1km反射率波段数据)的大小。或者如果想要扩n倍重采样,则不需要比值,只需要设置:
xsize = 1/n.0
ysize = 1/n.0
一定要.0
易错点2:
dims = [-1,0,ns0-1,0,nl0-1]
envi_doit,‘resize_doit’,fid = SOZ_fid,dims = dims,pos = pos,interp = 1,rfact = [xsize, ysize],out_name =outname ,r_fid = r_fid
在我们本科徐永明老师写的《遥感二次开发语言IDL》书中’resize_doit’这个过程后,对于dims的说明是“重采样后数据的空间范围”,而实际上此处应该是待重采样原始数据的dims,原始待重采样的空间范围。dims数组由一行五列元素组成,其中第一位如果不是用一个已经打开的ROI去重采样的话,就默认用-1,后面四位见下:
DIMS
The “dimensions” keyword is a five-element array of long integers that defines the spatial subset (of a file or array) to use for processing. Nearly every time you specify the keyword FID, you must also specify the spatial subset of the corresponding file (even if the entire file, with no spatial subsetting, is to be processed).

DIMS[0]: A pointer to an open ROI; use only in cases where ROIs define the spatial subset. Otherwise, set to -1L.
DIMS[1]: The starting sample number. The first x pixel is 0.
DIMS[2]: The ending sample number
DIMS[3]: The starting line number. The first y pixel is 0.
DIMS[4]: The ending line number


版权归作者 小白是哪个小白_ 所有,转载、引用请注明链接出处,侵权必纠!

  • 2
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值