[R-sig-Geo] Read HDF files

janverbesselt janverbesselt at gmail.com
Fri Sep 2 13:58:50 CEST 2011


You can try something like this;

# check out the raster and rgdal packages
library(raster)
library(rgdal)
# have the files in your current wd()
# for MODIS data MOD13C1 I do the following
fl <- list.files(pattern="\\.hdf$", recursive = TRUE) # without directories
GDALinfo(modis) # check out the name using this function
fndvi <- paste("HDF4_EOS:EOS_GRID:",fl[1],":MODIS_Grid_16Day_VI_CMG:CMG 0.05
Deg 16 days NDVI",sep='')

# then extract raster info and data and much more
system.time(data <- readGDAL(fndvi, offset=c(0,0), region.dim=c(1, 1))) #
centre is at (0,0)
parameters <- gridparameters(data)
res <- parameters$cellsize[1]
res

good luck.
Jan
http://www.grs.wur.nl/UK/Staff/Jan+Verbesselt/
http://bfast.r-forge.r-project.org/


--
View this message in context: http://r-sig-geo.2731867.n2.nabble.com/Read-HDF-files-tp6750856p6753611.html
Sent from the R-sig-geo mailing list archive at Nabble.com.



More information about the R-sig-Geo mailing list