编写一个pro程序,给定一个路径,自动获取该路径下所有的hdf4或h5文件,将其中某个数据转化为tif格式

题目要求

编写一个pro程序,给定一个路径,自动获取该路径下所有的hdf4或h5文件,将其中某个数据转化为tif格式

目录树即运行结果

具体文件我会放到百度网盘中
在这里插入图片描述

运行教程截图

  1. 编译
    在这里插入图片描述

  2. 运行
    在这里插入图片描述

  3. 选择图片 从grid中选择
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述

  4. 勾选
    在这里插入图片描述

代码和过程

pro homework_3_4_hdf_to_tiff
; 编写一个pro程序,给定一个路径,自动获取该路径下所有的hdf4或h5文件,将其中某个数据转化为tif格式
; the supported formats are: h5, hdf4, hdf, h4, he5, he2, hdf5

; 切换工作路径
cd, '/media/andy/Data/cs/IDL/third/'
;;设置支持的文件格式
file_path = dialog_pickfile(filter=['*.hdf', '*.hdf4', '*.h5'])
;判断是不是h5文件, 如是,进行h5的函数 否则进入h4的函数
is_h5_flag = h5f_is_hdf5(file_path)
if is_h5_flag then begin
  res = h5_to_tiff(file_path)
  
endif else begin
  res = h4_to_tiff(file_path)
endelse
end

function h4_to_tiff, file_path
; 将h4转为tiff格式
  hd_id = hdf_sd_start(file_path)
  template = hdf_browser(file_path)
  output_structure = hdf_read(file_path, template=template)
  ; 数组在结构体最后一个
  data =  output_structure.(3)
  write_tiff, 'res_3_4_h4_to_tiff.tif', data
  return, 1
end

function h5_to_tiff, file_path
  print, "the function is devploping..."
end

百度地址

链接: https://pan.baidu.com/s/1OPJw3DjiKSEW4UdqKmYmHA 密码: u84u
–来自百度网盘超级会员V4的分享

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值