Skip to content

extracting oceanographic data

1 message · Michael Sumner

#
LOUZAO wrote:
Yes, sorry I mean using readGDAL to read HDF/netCDF directly can be 
complicated since the default binary build won't have those drivers.  I 
would use gdal_translate to convert them to GeoTIFF first. GeoTIFF is 
easily the best raster format overall, but it depends on your needs.

Try this at the command line once FWTools is installed:

gdal_translate file.hdf out.tif

Then in R:

d <- readGDAL("out.tif")  ## with appropriate working directory

It all depends on exactly which files you mean, as it's likely these 
files have subdatasets - you can interrogate these names using gdalinfo, 
e.g.

gdalinfo file.hdf

It's well worth becoming familiar with FWTools and the GDAL command line 
utilities, and also the classes and methods in the sp package. rgdal 
package uses these classes and methods with the underlying GDAL 
framework for file I/O and projections, amongst other things.

That mkLookup function expects an xyz image list (see ?image ), and you 
can convert the results of a readGDAL call to that with 
as.image.SpatialGridDataFrame in the sp package.

I hope some of that helps, I can't spend time on the rest right now.

Cheers, Mike.