[gdal-dev] HDF4 trouble files

Lucena, Ivan ivan.lucena at pmldnet.com
Sun Nov 25 16:13:28 EST 2007


Joaquim,

Calling GetRasterCount from an HDF4 will always return 0 if you use only 
the file name to open it. In order to "see" bands you need to specify 
the subdataset string [http://www.gdal.org/frmt_hdf4.html] when you open 
it. And in order to see the subdatasets list you need to check the 
metadata, ex.: 
[http://trac.osgeo.org/gdal/browser/trunk/gdal/apps/gdalinfo.c#L284]

Best regards,

Ivan

Joaquim Luis wrote:
> Hi
> 
> I'm having troubles reading some of files available at
> http://oceancolor.gsfc.nasa.gov
> In particular the SST files but not the ocean color files.
> 
> What is happening is that on the problematic files
> 
> GDALGetRasterCount( hDataset );
> 
> is returning 0, which is fatal to my gdalread mex file.
> 
> Here is an example file
> http://oceancolor.gsfc.nasa.gov/cgi/getfile/T20061822006212.L3m_MO_SST_9.bz2 
> 
> Note that running gdalinfo on it does not print the
> Band 1 Block= ...
> 
> since that part of the code is inside a loop
> for( iBand = 0; iBand < GDALGetRasterCount( hDataset ); iBand++ )
> 
> and it's not executed since GDALGetRasterCount( hDataset ) == 0
> 
> 
> Joaquim Luis
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev
> 
> 


More information about the gdal-dev mailing list