An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20110901/cf94adcf/attachment.pl>
Read HDF files
6 messages · Arnaud Mosnier, Alexandre Castagna, Paul Hiemstra +1 more
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20110901/80957cf7/attachment.pl>
On 09/01/2011 05:20 PM, Arnaud Mosnier wrote:
Hi Geo UseRs, I am searching a way to read and manage HDF files in R (like files provided by the ocean color web site, http://oceancolor.gsfc.nasa.gov/). Thanks Arnaud [[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
The answer can be found by googling for "R read hdf". That leads to the HDF5 package or building GDAL with HDF support. Alternatively, find a (command)-line tool which can translate HDF5 to geotiff or netCDF (e.g. gdal_translate or ) and then use readGDAL or the ncdf package. Paul
Paul Hiemstra, Ph.D. Global Climate Division Royal Netherlands Meteorological Institute (KNMI) Wilhelminalaan 10 | 3732 GK | De Bilt | Kamer B 3.39 P.O. Box 201 | 3730 AE | De Bilt tel: +31 30 2206 494 http://intamap.geo.uu.nl/~paul http://nl.linkedin.com/pub/paul-hiemstra/20/30b/770
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.
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20110902/920999cd/attachment.pl>
Please have a look at the example I provided, it should work for your HDF4 files. The MODIS data I am dealing with comes in HDF4 format. I did not need to build a specific GDAL version that supports HDF4 format. I am using GDAL available via http://www.kyngchaos.com/software/frameworks for Mac OSx, and the latest version of rgdal for R2.13.1. In which environment are your working? Best, Jan
On 02/09/2011, at 3:36 PM, Arnaud Mosnier [via R-sig-geo] wrote:
Hi Paul, Thanks for your answer ... in fact I googled for that before asking this R list. Oceancolor HDF files are in HDF4 format and provided as two HDF4 format, in SIM (Standard Mapped Image) or BIN (binned). I first tried to use the BIN format without success. I use the gdal version provided with FWtools and gdal_info correctly identify the file as a HDF4 format, but it refuses to convert it to a geotiff. I finally succeeded using the SIM format. But, now I am interested in doing that directly into R. The version of gdal called by the library rgdal do not include support for HDF4 format. So my question is now ... can someone give me a step by step instruction that I can use to build a GDAL version including the support for HDF4 format (as it is the case in the version compiled with FWtools) ? Thanks, Arnaud 2011/9/2 Paul Hiemstra <[hidden email]>
On 09/01/2011 05:20 PM, Arnaud Mosnier wrote:
Hi Geo UseRs, I am searching a way to read and manage HDF files in R (like files
provided
by the ocean color web site, http://oceancolor.gsfc.nasa.gov/). Thanks Arnaud [[alternative HTML version deleted]]
_______________________________________________ R-sig-Geo mailing list [hidden email] https://stat.ethz.ch/mailman/listinfo/r-sig-geo
The answer can be found by googling for "R read hdf". That leads to the HDF5 package or building GDAL with HDF support. Alternatively, find a (command)-line tool which can translate HDF5 to geotiff or netCDF (e.g. gdal_translate or ) and then use readGDAL or the ncdf package. Paul -- Paul Hiemstra, Ph.D. Global Climate Division Royal Netherlands Meteorological Institute (KNMI) Wilhelminalaan 10 | 3732 GK | De Bilt | Kamer B 3.39 P.O. Box 201 | 3730 AE | De Bilt tel: +31 30 2206 494 http://intamap.geo.uu.nl/~paul http://nl.linkedin.com/pub/paul-hiemstra/20/30b/770
[[alternative HTML version deleted]]
_______________________________________________ R-sig-Geo mailing list [hidden email] https://stat.ethz.ch/mailman/listinfo/r-sig-geo If you reply to this email, your message will be added to the discussion below: http://r-sig-geo.2731867.n2.nabble.com/Read-HDF-files-tp6750856p6753885.html To unsubscribe from Read HDF files, click here.
-- View this message in context: http://r-sig-geo.2731867.n2.nabble.com/Read-HDF-files-tp6750856p6753935.html Sent from the R-sig-geo mailing list archive at Nabble.com.