[HDF]hdf-4.2.6类库的使用
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类库的使用的更多相关文章
- 【神经网络与深度学习】什么是HDF
什么是HDF HDF 是用于存储和分发科学数据的一种自我描述.多对象文件格式.HDF 是由美国国家超级计算应用中心(NCSA)创建的,以满足不同群体的科学家在不同工程项目领域之需要.HDF 可以表示出 ...
- How to compile and install NCAR Command Language on IBM PowerPC 64 --- NCL编译安装步骤
作者:Sinsonglew 出处:http://www.cnblogs.com/sinsonglew 欢迎转载,也请保留这段声明.thanks :) 注记:NCL官方依赖安装包全集列表.官方源码编译指 ...
- 了解GDAL的图像处理/Python
GDAL是一个操作各种栅格地理数据格式的库.包括读取.写入.转换.处理各种栅格数据格式(有些特定的格式对一些操作如写入等不支持).它使用了一个单一的抽象数据模型就支持了大多数的栅格数据(GIS对栅格, ...
- CentOS7搭建 Hadoop + HBase + Zookeeper集群
摘要: 本文主要介绍搭建Hadoop.HBase.Zookeeper集群环境的搭建 一.基础环境准备 1.下载安装包(均使用当前最新的稳定版本,截止至2017年05月24日) 1)jdk-8u131 ...
- Python的工具包[1] -> pandas数据预处理 -> pandas 库及使用总结
pandas数据预处理 / pandas data pre-processing 目录 关于 pandas pandas 库 pandas 基本操作 pandas 计算 pandas 的 Series ...
- python 读hdf4文件,再转写成一个tif文件
1.安装pyhdf包 (1)通过此链接查找并下载pyhdf包:https://www.lfd.uci.edu/~gohlke/pythonlibs/#pygame(根据自己的系统及python版本选择 ...
- hdf第二周,每天加班,周末加班,周日健身
----------------------------------------------------------------------------- 受到挫折,写一些简单的练习,增加成就感 放大 ...
- [GDAL]读取HDF格式的calipso数据
探测地球云层分布的CloudSat和CALIPSO卫星 http://www.nasa.gov/mission_pages/calipso/main/index.html http://www.nas ...
- Hadoop处理HDF文件
1.前言 HDF文件是遥感应用中一种常见的数据格式,因为其高度结构化的特点,笔者曾被怎样使用Hadoop处理HDF文件这个问题困扰过相当长的一段时间.于是Google各种解决方式,但都没有找到一种理想 ...
随机推荐
- 【液晶模块系列基础视频】3.1.fatfs文件系统的移植及接口函数的使用
============================== 技术论坛:http://www.eeschool.org 博客地址:http://xiaomagee.cnblogs.com 官方网店:h ...
- Javascript 笔记与总结(1-5)闭包
[例1] <script> function t1(){ var age = 20; function t2(){ alert(age); } return t2; } var tmp = ...
- UItableview section和cell的局部刷新
局部刷新//一个section刷新 NSIndexSet *indexSet=[[NSIndexSet alloc]initWithIndex:2]; [tableview reloadS ...
- 正则匹配中文.PHP不兼容的问题
不使用: ^[\u4e00-\u9fa5_a-zA-Z0-9_]+$ 有可能兼容有问题 if(!preg_match_all("/^[\\x7f-\\xff_a-zA-Z0-9]+$/&qu ...
- Unity3D之游戏架构脚本该如何来写(转)
这篇文章主要想大家说明一下我在Unity3D游戏开发中是如何写游戏脚本的,对于Unity3D这套游戏引擎来说入门极快,可是要想做好却非常的难.这篇文章的目的是让哪些已经上手Unity3D游戏引擎的朋友 ...
- using System.Diagnostics; 日志操作
using System.Diagnostics 命名空间 包含了能够与系统进程 事件日志 和性能计数器进行交互的类 一般用于帮助诊断和调试应用程序 例如 Debug类用于帮组调试代码 Process ...
- 【转载】MySQL性能优化的最佳20+条经验
今天,数据库的操作越来越成为整个应用的性能瓶颈了,这点对于Web应用尤其明显.关于数据库的性能,这并不只是DBA才需要担心的事,而这更是我们程序员需要去关注的事情.当我们去设计数据库表结构,对操作数据 ...
- push to deploy
1.server端 建立裸仓 $ mkdir ~/repo.git $ cd ~/repo.git $ git init --bare 脚本 $ vim ~/repo.git/hooks/post-r ...
- Scripting Languages
Computer Science An Overview _J. Glenn Brookshear _11th Edition A subset of the imperative programmi ...
- Java构造和解析Json数据的两种方法详解二
在www.json.org上公布了很多JAVA下的json构造和解析工具,其中org.json和json-lib比较简单,两者使用上差不多但还是有些区别.下面接着介绍用org.json构造和解析Jso ...