[R-sig-Geo] Read HDF files
Roger Bivand
Roger.Bivand at nhh.no
Sun Sep 4 15:25:47 CEST 2011
On Sat, 3 Sep 2011, Arnaud Mosnier wrote:
> Hi Jan,
>
> Thanks for you answer.
> I tried your script but unfortunatly it does not work for my case.
No, you did not. He is using rgdal built against an OSX framework GDAL
that includes an HDF driver. If you type gdalDrivers() on your CRAN rgdal
built statically against a minimal GDAL, you will see that you do not have
an HDF driver. You need either to install rgdal from source linked to a
GDAL that has the HDF driver (which I assume you do not want to do - see
file.show(system.file("README.windows", package="rgdal")) for details if
you do), or to use external software, such as a Windows version of
gdal_translate to convert your HDF file to for example GTiff outside R,
and then use the minimal set of drivers included in the CRAN rgdal to read
the data.
GDAL potentially has well over 100 drivers, many of which must be linked
against external libraries. It is not practically possible to build the
CRAN Windows rgdal binaries (or the CRAN Extras OSX rgdal binaries) for
more than a minimal set with very few external dependencies. A source of
Windows GDAL binaries is:
http://www.gisinternals.com/sdk/
linked from:
http://trac.osgeo.org/gdal/wiki/DownloadingGdalBinaries
from:
http://www.gdal.org/
Hope this helps,
Roger
> If someone want to make some test with the kind of image I want to use, just
> try this script to download and uncompress it.
>
> TestFolder <- choose.dir()
>
> download.file("
> http://oceandata.sci.gsfc.nasa.gov/cgi/getfile/A20072132007243.L3m_MO_CHL_chlor_a_4km.bz2",
> f<-paste(TestlFolder, "/hdf4test.bz2", sep = "")
> library(R.utils)
> gunzip(f, f2<-paste(TestFolder, "/testhdf4.hdf", sep = "")
> GDALinfo(f2) # in my case it results on this message
> `C:/test/testhdf4.hdf' not recognised as a supported file format.
>
>
>
> Here is my sessionInfo() result.
>
> R version 2.12.0 (2010-10-15)
> Platform: x86_64-pc-mingw32/x64 (64-bit)
>
> locale:
> [1] LC_COLLATE=French_Canada.1252 LC_CTYPE=French_Canada.1252
> LC_MONETARY=French_Canada.1252 LC_NUMERIC=C
> LC_TIME=French_Canada.1252
>
> attached base packages:
> [1] grDevices datasets splines graphics stats tcltk utils
> methods base
>
> other attached packages:
> [1] R.utils_1.7.8 R.oo_1.8.1 R.methodsS3_1.2.1 rgdal_0.7-1
> raster_1.9-5 sp_0.9-84 svSocket_0.9-51 TinnR_1.0.3
> R2HTML_2.2 Hmisc_3.8-3 survival_2.35-8
>
> loaded via a namespace (and not attached):
> [1] cluster_1.14.0 grid_2.12.0 lattice_0.19-33 svMisc_0.9-61
> tools_2.12.0
>
>
> Thanks for any help !
>
> 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
>
--
Roger Bivand
Department of Economics, NHH Norwegian School of Economics,
Helleveien 30, N-5045 Bergen, Norway.
voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no
More information about the R-sig-Geo
mailing list