[GIS] Processing HDF4 data in R

gdalhdfrrgdal

I am trying to process MODIS files in R, which are in HDF4 format (link to data). I have experience reading in HDF5 and netCDF files in R, but HDF4 seems to be a common problem in R. I am using a MAC (Mountain Lion OS X 10.8.5), and have found the following webpages (link1, link2) helpful in setting up GDAL and the r package, rgdal. My problem is that is doesn't look like I have any HDF4 drivers, and I'm wondering what step I have missed?

library(rgdal)
gdalDrivers()

...
...
44              GTX                                 NOAA Vertical Datum .GTX   TRUE FALSE
45              GXF                             GeoSoft Grid Exchange Format  FALSE FALSE
46             HDF5                       Hierarchical Data Format Release 5  FALSE FALSE
47        HDF5Image                                             HDF5 Dataset  FALSE FALSE
48              HF2                               HF2/HFZ heightfield raster  FALSE  TRUE
49              HFA                              Erdas Imagine Images (.img)   TRUE  TRUE
...
...

So, nothing listed for HDF4 as shown in point 6.2 of the example. Does anyone know what my problem might be? The issue of reading HDF4 data into R seems to be a common one. I would have no problem doing some sort of batch conversion to HDF5 or netCDF if someone has a suggestion for this.

Best Answer

I developed gdalUtils specifically for this issue. On a Mac, install the GDAL frameworks which include HDF4/5 and NetCDF drivers, and then use gdalUtils to interface with it.

Related Question