[R-sig-Geo] reading HDF 4 files into R

Roger Bivand Roger.Bivand at nhh.no
Thu May 27 16:49:29 CEST 2010


On Thu, 27 May 2010, Burton Shank wrote:

> Hi all,
>
> We're trying to process large amounts of remote-sensing data currently
> stored in hdf v4 formats.  I expect there may be a simple way to read these
> files directly into R (ideally as a spatial pixels data frame) but can't
> find the right function.  It seems that it may be possible to use readGDAL
> or readOGR but I can't find an appropriate syntax in the documentation.
>
> Most people seem to pre-process these files into an hdf_5 or netDCS before
> importing, and this would be acceptable except we're looking to process
> hundreds of files and would rather avoid learning another scripting language
> just for batch pre-processing.  Are there any freeware programs that can
> easily perform such batch-processing?
>
> For a sample file, go to
> http://oceandata.sci.gsfc.nasa.gov/SeaWiFS/Mapped/8Day/chlor/1997/
> download any .bz2 file and unzip.
>
> The unzipped files are in hd_4 format, though they don't have any file
> extension (.hdf or .h4).

On a platform with GDAL built with the HDF4 driver, rgdal would cover 
this, with some requirements with regard to the organisation of the data. 
If the driver is not available, you could batch-convert to one of the 
drivers that are available for rgdal for that platform. Since you do not 
state your platform, I assume it is Windows. There, using for example an 
OSGEO4W build of GDAL will probably include HDF4, but the Windows 32/64 
bit builds of GDAL shipped with binary rgdal do not. So from R you would 
use system() to call gdal_translate to get from HDF4 to say GTiff. On a 
platform where you build your own GDAL, then install rgdal from source, 
you should have the driver there for you:

http://www.gdal.org/frmt_hdf4.html

Hope this helps,

Roger

>
> Any assistance is appreciated.
>
> Burton Shank
> Northeast Fisheries Science Center
> Woods Hole, MA
>
> 	[[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no



More information about the R-sig-Geo mailing list