Skip to content
Prev 4880 / 29559 Next

readGDAL() and HDF5 files

On Fri, 23 Jan 2009, Sebastian P. Luque wrote:

            
Please do provide full version data for R, rgdal, GDAL, and the GDAL 
drivers, including the HDF5 libraries. I did - please do the same: all 
tests on Windows, OSGeo4W GDAL 1.5.4 with released drivers:

http://download.osgeo.org/osgeo4w/osgeo4w-setup.exe

and unreleased Windows binary rgdal_0.6-6 from:

http://spatial.nhh.no/R/Devel/rgdal_0.6-6.zip

Then at least we are comparing like with like. Nothing should segfault 
under any circumstances (though the GDAL HDF5 driver segfaults for me when 
asking for non-existent data[01]). A fuller report on the NetCDF case 
would be helpful.

My feeling at the moment is that the file is not self-documenting itself 
in a portable way, because GDAL does read the data in an order that isn't 
what the file header claims.
The dimensions are what the file declares - I suspect that software within 
the originator institution knows that they are reversed, and does the 
same, but this isn't portable. I further suspect that the 1120x1 block 
size is not helpful, and probably should be 760x1. See below for analysis.
No, see below, you are reversing axes in gdalinfo:
No, exactly as the GDAL driver does, 760 rows and 1120 columns, left is 0, 
right is 1120, upper is 0, lower is 760.

upper left (0,0)                        upper right (1120, 0)

lower left (0,760)                      lower right (1120, 760)

So either the GDAL driver is broken, or the data in the file is not in 
sync with its metadata.

So far I get your figure by molesting the input metadata:

ice <- readGDAL("HDF5:\"conc_200901011200.hdf\"://Data/data[00]",
  p4s=as.character(NA))
is.na(ice$band1) <- ice$band1 < 0
vice <- ice$band1
mice <- matrix(vice, ncol=760, byrow=TRUE)
image(t(mice[1120:1,]), asp=1)

As I said before, the input HDF5 file has a completely wrong description 
of its own projection, so my conclusion would be that it is so badly 
configured as not to be usable in a portable way, since both its geometry 
and projection are declared in error.

Hope this helps,

Roger