[R-sig-Geo] reading .hdf files

Jonathan Greenberg jgrn at illinois.edu
Tue Mar 25 18:09:22 CET 2014


We wrote a package initially inspired by this issue -- gdalUtils,
which are wrappers for the GDAL/OGR utilities.  There are even some
hdf helper functions we included (e.g. ?get_subdatasets).  Note that
if you are on a Windows or Mac box, it is important you install the
correct version of GDAL first.

Currently, you'll need to extract out the subdataset you want via
?gdal_translate -- there is an example using an HDF4 file in the help.

I would recommend grabbing the R-forge version, since I have a few
fixes in there that aren't on the latest CRAN:

install.packages("gdalUtils", repos="http://R-Forge.R-project.org")

Good luck!


On Tue, Mar 25, 2014 at 11:54 AM, Barry Rowlingson
<b.rowlingson at lancaster.ac.uk> wrote:
> HDF is a richer file format, and can do more than just store rasters. It
> can contain multiple objects of different dimension.
> There's a few ad-hoc standards for regular raster data in HDF though, where
> objects in the HDF specify the coordinates on the axes - which might be
> lat, lon, time, height  in a 4-D data set and then the 4d hypercube of data
> itself.
> See the Binary Data Formats section here:
>  http://cran.r-project.org/doc/manuals/r-release/R-data.html
> for some packages that can read HDF, but you might have to dig into the
> metadata to work out how to get the NDVI raster for 01/2012 from your HDF
> file. Without a sample, we're guessing...
> Barry
> On Tue, Mar 25, 2014 at 4:37 PM, dododave <dododave at gmail.com> wrote:
>> Hi all,
>> I am trying to load an hdf raster file consisting of NDVI values so that I
>> can calculate the mean values within a polygon. I have been able to do this
>> with GEOtiff files, but not with .hdf, which is strange because GIS
>> programs
>> can readily load them.
>> I have looked into rgdal package, but that doesn't seem to have an hdf
>> driver
>> Thanks for any help,
>> Dave
>> --
>> View this message in context:
>> http://r-sig-geo.2731867.n2.nabble.com/reading-hdf-files-tp7586038.html
>> Sent from the R-sig-geo mailing list archive at Nabble.com.
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo at r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>         [[alternative HTML version deleted]]
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Jonathan A. Greenberg, PhD
Assistant Professor
Global Environmental Analysis and Remote Sensing (GEARS) Laboratory
Department of Geography and Geographic Information Science
University of Illinois at Urbana-Champaign
259 Computing Applications Building, MC-150
605 East Springfield Avenue
Champaign, IL  61820-6371
Phone: 217-300-1924
AIM: jgrn307, MSN: jgrn307 at hotmail.com, Gchat: jgrn307, Skype: jgrn3007

More information about the R-sig-Geo mailing list