[R-sig-Geo] How to open and work with an .hdf map

Michael Sumner mdsumner at gmail.com
Fri Jul 6 13:32:17 CEST 2012


Another option is the GDAL tools, if you can deal with the translation
of (potentially) 3+D arrays into GIS-alike raster layers. You'd have
to build your own rgdal with HDF support on Windows (which is hard),
but you can use the GDAL command-line tools that come with an OSGeo4W
installation.

These pages describe the details and usage:

http://www.gdal.org/frmt_hdf4.html
http://www.gdal.org/frmt_hdf5.html

A default gdal_translate will produce a GeoTIFF which can be read
directly by rgdal::readGDAL or raster::raster.

I will try your file if I can.

Cheers, Mike.

On Fri, Jul 6, 2012 at 8:39 PM, Matthew Landis <landis at isciences.com> wrote:
> Marc,
>
> It's been a long time since I worked with HDF, so someone out there will
> likely have better suggestions.  But I think you will want to get that out
> of HDF format as fast as possible.  Try using hdp
> (http://www.hdfgroup.org/hdp.html) to dump the file to a binary or ascii
> file and then you should be able to read that in to R using readBin or
> read.delim or such.
>
> There are also hdf viewers at the HDFGroup site that should help you to see
> what the file looks like, figure out the grid, etc.
>
> M
>
>
> On 7/6/2012 5:32 AM, Marc Marí Dell'Olmo wrote:
>>
>> Hello,
>>
>> I'm trying to open and work with a map I have downloaded from
>> http://glovis.usgs.gov/, obtained from MODIS Terra satellite. This web
>> only allows to download maps in .hdf format. I do not have ArcView, a GIS
>> programme which opens these maps without any problem. I have been trying
>> to
>> do it using "R", however, I have not succeeded... First, I converted the
>> map
>> - which is in version 4 - to version 5 (with h4h5tools
>> http://www.hdfgroup.org/h4toh5). I have tried to open it with satinGet
>> (library satin) but I have obtained this error message:
>> Error en queryname(nom.hdf5, what = "date") :
>>   objeto 'date.str' no encontrado
>>
>> Finally I managed to open the file using the function hdf5load (library
>> hdf5). With this function I have obtained two objects   "HDF4_DIMGROUP" ,
>> "MOD44B_250m_GRID" but I don't know how can I represent spatially the
>> data.
>> I think I have a grid with the values of the variables but I don't know
>> the
>> reference of the coordinates (UTM long lat), the distance between the
>> points
>> of the grid, etc... In general, I don't know how to work with the
>> information...
>>
>> I'm using Windows.
>>
>> Here is the link of the original map, in case it helps.
>>
>> http://dl.dropbox.com/u/22891835/MOD13Q1NDVI_2012Maig.hdf
>>
>> Thanks in advance for the help!
>>
>> Marc
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo at r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
>
> --
> ~~~~~~~~~~~~~~~~~~~~~~~~~~
> Matthew Landis, Ph.D.
> Research Scientist
> ISciences, LLC
> 61 Main St. Suite 200
> Burlington VT 05401
> 802.864.2999
> www.isciences.com
> ~~~~~~~~~~~~~~~~~~~~~~~~~~
>
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo



-- 
Michael Sumner
Hobart, Australia
e-mail: mdsumner at gmail.com



More information about the R-sig-Geo mailing list