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. 初探Bootstrap之十二栅格

    模型1: <!-- 4/12 --> <div class="container"> <div class="row"> & ...

  2. HDU 1043 & POJ 1077 Eight(康托展开+BFS+预处理)

    Eight Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 30176   Accepted: 13119   Special ...

  3. 清橙 A1206 小Z的袜子(莫队算法)

    A1206. 小Z的袜子 时间限制:1.0s   内存限制:512.0MB   总提交次数:1357   AC次数:406   平均分:46.75   将本题分享到:        查看未格式化的试题 ...

  4. PHP mkdir 方法 创建 0777 权限的目录问题

    php 中使用 mkdir() 方法创建 0777 权限的目录: $path = './Logs/secondCheck/';if(!is_dir($path)){ mkdir($path, 0777 ...

  5. 【翻译】CEDEC2015 速成Albedo Chart 制作

        关于pbr材质和贴图的制作,最近llegorithmic提供了几篇不错的guide  https://www.allegorithmic.com/pbr-guide   不过像如何从通过现实场 ...

  6. php--某个字符在字符串中的位置比较

    <?php $haystack = 'helloe'; $needle = 'e'; $pos = stripos($haystack, $needle); echo "\n" ...

  7. 八 mybatis查询缓存(一级缓存,二级缓存)和ehcache整合

    1       查询缓存 1.1     什么是查询缓存 mybatis提供查询缓存,用于减轻数据压力,提高数据库性能. mybaits提供一级缓存,和二级缓存.

  8. vector 初始化所有方法

    简介:vector可用于代替C中的数组,或者MFC中的CArray,从许多说明文档或者网上评论,一般一致认为应该多用vector,因为它的效率更高,而且具备很好的异常安全性.而且vector是STL推 ...

  9. 估值十亿美元、1.5亿用户,公司CEO却跑路了

    转载这篇文章是觉得配图非常好玩的,文章的真实性有待证明 年收益3600万美元的.曾经拥有高口碑产品的Evernote,却正在把一手好牌打烂,距离IPO越来越远,屡屡被业界唱衰. "独角兽公司 ...

  10. Ubuntu 14.04 在桌面上双击运行shell 脚本文件

    http://askubuntu.com/questions/465531/how-to-make-a-shell-file-execute-by-double-click up vote7down ...