HDF文件包括科学数据和VData部分。读取HDF格式的calipso数据,用GDAL可以方便的读取其中的子数据集,但是没有发现GDAL中提供读取Vdata的方法。所以只好考虑借助hdf-4.2.6类库本身。毕竟GDAL也是采用的hdf-4.2.6类库进行了一次封装。

首先从HdfGroup网站下载一个编译好的安装包。解压后目录如下:

新建一个Win32控制台项目。

添加包含和引用的lib,注意安装目录文件夹下的lib文件夹中的.lib文件应该是relese版本的,我这里引用了dll文件夹下的.lib文件。

从Hdf4.2.6源码中找到VD_create_onefield_vdatas.c文件。我这里修改为VD_create_onefield_vdatas.cpp,添加到项目中,把项目中的HdfFirst.cpp直接排除掉,因为里面有个Main函数。

同时在VD_create_onefield_vdatas.cpp添加

#include "stdafx.h"

完整代码:

 #include "stdafx.h"
#include "hdf.h" #define FILE_NAME "General_Vdatas.hdf"
#define CLASS1_NAME "5x1 Array"
#define CLASS2_NAME "6x4 Array"
#define VDATA1_NAME "First Vdata"
#define VDATA2_NAME "Second Vdata"
#define FIELD1_NAME "Single-component Field"
#define FIELD2_NAME "Multi-component Field"
#define N_RECORDS_1 5 /* number of records the first vdata contains */
#define N_RECORDS_2 6 /* number of records the second vdata contains */
#define ORDER_2 4 /* order of the field in the second vdata */
/* Note that the order of the field in the first vdata is 1 */ int main( )
{
/************************* Variable declaration **************************/ intn status_n; /* returned status for functions returning an intn */
int32 status_32; /* returned status for functions returning an int32 */
int32 file_id, vdata1_ref, vdata2_ref; /*
* Define an array to buffer the data of the first vdata.
*/
char8 vdata1_buf [N_RECORDS_1] = {'V', 'D', 'A', 'T', 'A'}; /*
* Define an array to buffer the data of the second vdata.
*/
int32 vdata2_buf [N_RECORDS_2][ORDER_2] = {{, , , }, {, , , },
{, , , }, {, , , },
{, , , }, {, , , }}; /********************** End of variable declaration **********************/ /*
* Open the HDF file for writing.
*/
file_id = Hopen (FILE_NAME, DFACC_WRITE, ); /*
* Initialize the VS interface.
*/
status_n = Vstart (file_id); /*
* Create the first vdata and populate it with data from the vdata1_buf
* array. Note that the buffer vdata1_buf is cast to (uint8 *) for the
* benefit of generic data type.
*/
vdata1_ref = VHstoredata (file_id, FIELD1_NAME, (uint8 *)vdata1_buf,
N_RECORDS_1, DFNT_CHAR8, VDATA1_NAME, CLASS1_NAME); /*
* Create the second vdata and populate it with data from the vdata2_buf
* array.
*/
vdata2_ref = VHstoredatam (file_id, FIELD2_NAME, (uint8 *)vdata2_buf,
N_RECORDS_2, DFNT_INT32, VDATA2_NAME, CLASS2_NAME, ORDER_2); /*
* Terminate access to the VS interface and close the HDF file.
*/
status_n = Vend (file_id);
status_32 = Hclose (file_id);
return ;
}

将Dll文件拷贝到Debug目录下,运行,发现目录下生成了General_Vdatas.hdf文件。在Matlab中查看:

[HDF]hdf-4.2.6类库的使用的更多相关文章

  1. 【神经网络与深度学习】什么是HDF

    什么是HDF HDF 是用于存储和分发科学数据的一种自我描述.多对象文件格式.HDF 是由美国国家超级计算应用中心(NCSA)创建的,以满足不同群体的科学家在不同工程项目领域之需要.HDF 可以表示出 ...

  2. How to compile and install NCAR Command Language on IBM PowerPC 64 --- NCL编译安装步骤

    作者:Sinsonglew 出处:http://www.cnblogs.com/sinsonglew 欢迎转载,也请保留这段声明.thanks :) 注记:NCL官方依赖安装包全集列表.官方源码编译指 ...

  3. 了解GDAL的图像处理/Python

    GDAL是一个操作各种栅格地理数据格式的库.包括读取.写入.转换.处理各种栅格数据格式(有些特定的格式对一些操作如写入等不支持).它使用了一个单一的抽象数据模型就支持了大多数的栅格数据(GIS对栅格, ...

  4. CentOS7搭建 Hadoop + HBase + Zookeeper集群

    摘要: 本文主要介绍搭建Hadoop.HBase.Zookeeper集群环境的搭建 一.基础环境准备 1.下载安装包(均使用当前最新的稳定版本,截止至2017年05月24日) 1)jdk-8u131 ...

  5. Python的工具包[1] -> pandas数据预处理 -> pandas 库及使用总结

    pandas数据预处理 / pandas data pre-processing 目录 关于 pandas pandas 库 pandas 基本操作 pandas 计算 pandas 的 Series ...

  6. python 读hdf4文件,再转写成一个tif文件

    1.安装pyhdf包 (1)通过此链接查找并下载pyhdf包:https://www.lfd.uci.edu/~gohlke/pythonlibs/#pygame(根据自己的系统及python版本选择 ...

  7. hdf第二周,每天加班,周末加班,周日健身

    ----------------------------------------------------------------------------- 受到挫折,写一些简单的练习,增加成就感 放大 ...

  8. [GDAL]读取HDF格式的calipso数据

    探测地球云层分布的CloudSat和CALIPSO卫星 http://www.nasa.gov/mission_pages/calipso/main/index.html http://www.nas ...

  9. Hadoop处理HDF文件

    1.前言 HDF文件是遥感应用中一种常见的数据格式,因为其高度结构化的特点,笔者曾被怎样使用Hadoop处理HDF文件这个问题困扰过相当长的一段时间.于是Google各种解决方式,但都没有找到一种理想 ...

随机推荐

  1. Spring框架中的定时器 如何使用和配置

    目标类 <bean id="myTimer" class="com.timer.MyTimer"></bean> 配置你的定时器详情 & ...

  2. PHP 错误与异常 笔记与总结(12 )异常

    ① 异常的概念:异常和错误的区别 PHP 部分借鉴了 C++ 和 JAVA 中的异常处理机制.PHP 中的异常是指 程序运行和预期不太一致,与错误是两个不同的概念. ② 异常的语法结构 [例1] &l ...

  3. Javascript 笔记与总结(2-5)window 对象

    浏览器 window 对象(BOM)是浏览器宿主对象,和 js 语言无关. [window 对象的方法] window.alert(message); window.confirm(message); ...

  4. 优秀而又实用的PHP工具集锦

    优秀而又实用的PHP工具集锦   浏览:1141 发布日期:2013/09/04 分类:技术分享 PHP是目前实用最为广泛的服务器端开源脚本语言之一,很多优秀的开源程序都是基于PHP构建的,比如大名鼎 ...

  5. jQuery Questions:Front-end Developer Interview Questions

    Explain "chaining". Chaining allows us to run multiple jQuery methods (on the same element ...

  6. jQuery 利用 $.getJson() 实现跨域

    数据量不大时,跨域的不二之选,而且操作简单,易上手. a.com/test.html //这里我假定有一些数据: var formData = form.serialize(); //这里的jsonc ...

  7. Sign-Magnitude Representation

    COMPUTER ORGANIZATION AND ARCHITECTURE DESIGNING FOR PERFORMANCE NINTH EDITION There are several alt ...

  8. IOS NSDate NSDateFormatter 导致相差8小时

    时间问题应该是所有编程语言都要处理的.详细学过php的同学知道,php中也会有相差8小时的问题,然而php可以非常方便的解决的,直接设置下就好了 我最近在学习IOS的过程中,发现IOS的日期处理也是个 ...

  9. IOS 入门开发教程

    object-c: http://mobile.51cto.com/iphone-261129.htm Objective-C入门教材 Objective-C入门教材 2011-05-11 15:58 ...

  10. go 安装

    安装golang centos7 直接安装golang yum install golang centos6需添加软件源,然后再安装 rpm -ivh http://ftp.riken.jp/Linu ...