[R-sig-Geo] reading and reformatting hdf files within raster

Dutrieux, Loic loic.dutrieux at wur.nl
Sat May 25 17:40:17 CEST 2013


Hi Joseph,

There is a MODIS package that has many useful utilities for downloading, reading, reprojecting, ... MODIS (HDF4) data.

library(raster)
library(MODIS)
sds <- getSds('filename.hdf') # Make sure to use full path
evi <- raster(sds$SDS4gdal[2]) # REad SDS 2 of the hdf file (EVI)

# Or eventually
evi <- raster(readGDAL(sds$SDS4gdal[2], as.is = TRUE))

The second option allows to have control over the otherwise by default scaling of the data. It can be useful when the scaling factor provided by the metadata is incorrect, which I think is the case for this particular MODIS product.

Cheers,

--
Loïc Dutrieux
Laboratory of Geo Information Science and Remote Sensing
Wageningen University
The Netherlands


________________________________________
From: r-sig-geo-bounces at r-project.org [r-sig-geo-bounces at r-project.org] on behalf of Barry Rowlingson [b.rowlingson at lancaster.ac.uk]
Sent: Saturday, May 25, 2013 5:10 PM
To: Jonathan Greenberg
Cc: r-sig-geo at r-project.org
Subject: Re: [R-sig-Geo] reading and reformatting hdf files within raster

On Sat, May 25, 2013 at 2:17 PM, Jonathan Greenberg <jgrn at illinois.edu> wrote:
> Is it is possible to read a MODIS HDF "layer" directly with a raster()
> statement?

 Have you tried searching for HDF on CRAN?

http://cran.r-project.org/web/packages/h5r/index.html

I don't fancy downloading a 196MB MODIS file to find out...

Barry

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo at r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo




More information about the R-sig-Geo mailing list