[GIS] import he5 files into R

hdfr

I want to import he5 irradiance files from giovanni. See a list here.
This post shows how to import he5 files into QGIS, but I'd like to import them into R. Is it possible? I tried package rhdf5 but couldn't find how to do it.

Best Answer

You need to use two packages, raster and ncdf4. The first one will let you open raster file; the second one, to assign ncdf4 space into raster package and view metadata. Important: is necessary to select Data field, you can't open all Data field at the same time (or at less I don't know how to do it without a for or do.call function). An example with the file that you give us:

library(raster)
library(ncdf4)

# View Data fields
nc_open("/path/to/OMI-Aura_L3-OMUVBd_2004m1001_v003-2016m0525t164359.he5")

File /path/to/OMI-Aura_L3-OMUVBd_2004m1001_v003-2016m0525t164359.he5 (NC_FORMAT_NETCDF4):

     19 variables (excluding dimension variables):
        float Data Fields/CSErythemalDailyDose[Data Fields/phony_dim_1,Data Fields/phony_dim_0]   (Chunking: [90,23])  (Compression: level 5)
            MissingValue: -1.26765060022823e+30
            Offset: 0
            ScaleFactor: 1
            _FillValue: -1.26765060022823e+30
            Title: Clear Sky Erythemal Daily Dose
            UniqueFieldDefinition: OMI-Specific
            Units: J/m2
.
.
.

# Open Data field as raster
r <- raster("/path/to/OMI-Aura_L3-OMUVBd_2004m1001_v003-2016m0525t164359.he5",
            var="Data Fields/CSIrradiance324",ncdf=TRUE)

plot(r)

rplot