[gdal-dev] Are all Files of HDF5 Formats supported by Gdal with libhdf5?

atubar atubar at 126.com
Tue Sep 8 00:55:07 EDT 2009


Hi, I'm not quite sure about what you need to analyze the problem. But I will write down all details which I consider helpful.

I build all dlls (gdal_HDF5.dll, gdal_HDF5Image.dll), add C:\gdal\gdal162\bld\bin as system variable.

Then I reset VS2008 as VC++ with default settings, add C:\gdal\gdal162\bld\include and C:\gdal\gdal162\bld\lib to the project.

The sample datas are supplied as part of software package. Theit file structures are below read out by The HDF hdfview 2.5.

-----------Structure of sample data from hdfview 2.5----------------
C:\Program Files\thg\hdfview 2.5\samples\hdf5_test.h5
+hdf5_test.h5
   +A note
   +arrays
     -1D String
     -2D float array
     -2D int array
     -3D int array
     -ArrayOfStructures
     -Vdata with mixed types
   +datatypes
     -H5_NATIVE_INT
   +images
     -3D THG
     -Iceberg
     -hst_lagoon_detail.jpg
     -ice interlace
     -pixel interlace
     -plane interlace


-----------Structure of sample data from Envi 4.3----------------
D:\RSI\IDL63\examples\data\hdf5_test.h5
+hdf5_test.h5
    -2D int array
    -A note
    -SL to 3D int array
    +arrays
       -2D float array
       -2D int array
       -3D int array
       -Vdata with mixed types
    +datatypes
       -A Native float datatype
       -A String datatype
       -Air pressure
    +images
       -Eskimo
       -Eskimo_palette
       -Iceberg
       -Iceberg_palette
    +links
       +hard links
           -Eskimo
           -RGB values
           -loop back to links
        +soft links
           -2D float array


-------------------------the code that I write in VS2008 ------------------------
#include <iostream>
#include <stdio.h>

#include "gdal_priv.h"
#pragma comment(lib,"gdal_i.lib")

using std::cout;
using std::endl;

int main()
{
 GDALAllRegister();

 const char* filename="D:\\RSI\\IDL63\\examples\\data\\hdf5_test.h5";
 //const char* filename="C:\\Program Files\\thg\\hdfview 2.5\\samples\\hdf5_test.h5";

 const char* pszFormat="HDF5";
 GDALDriver *poDriver = GetGDALDriverManager()->GetDriverByName(pszFormat);
 
 if( poDriver != NULL )
 {
  cout<<pszFormat<<" format is supported!"<<endl;
 }
 else
 {
  cout<<"Gdal do not support "<<pszFormat<<"."<<endl;
 }

 GDALDataset *poDataset; 
 poDataset= (GDALDataset *) GDALOpen( filename, GA_ReadOnly);
 
 if(poDataset == NULL)
 {
  cout<<"error!";
  return 0;
 }
  else
 {
  //***************************************************************//
  double   adfGeoTransform[6];
  
  printf( "Driver: %s/%s\n",
   poDataset->GetDriver()->GetDescription(), 
            poDataset->GetDriver()->GetMetadataItem( GDAL_DMD_LONGNAME ) );
  
  printf( "Size is %dx%dx%d\n", 
            poDataset->GetRasterXSize(), poDataset->GetRasterYSize(),
            poDataset->GetRasterCount() );
  
  if( poDataset->GetProjectionRef()  != NULL )
   printf( "Projection is '%s'\n", poDataset->GetProjectionRef() );
  
  if( poDataset->GetGeoTransform( adfGeoTransform ) == CE_None )
  {
   printf( "Origin = (%.6f,%.6f)\n",
    adfGeoTransform[0], adfGeoTransform[3] );
   
   printf( "Pixel Size = (%.6f,%.6f)\n",
                adfGeoTransform[1], adfGeoTransform[5] );
  }
 }
 
 GDALClose(poDataset);
 return 0;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20090908/b00e9e53/attachment-0001.html


More information about the gdal-dev mailing list