I already asked this question @stackoverflow however, perhaps it fits better here, due to the spatial nature of VIIRS data and the hdf5-eos file format.
Im looking into how to handle .h5 (hdf-eos) VIIRS DNB raster data in R (or any other opensource software). I know that GeoTIFF products are available, for monthly composites, however I need daily data, that is why I need to work with the .h5.
My data is ordered and downloaded through https://www.class.ngdc.noaa.gov/saa/products/welcome
Preferably I want to be able to plot and create time series of the data in R, but if that is not possible, then I want to export it as GeoTIFF to handle it in ArcGIS or QGIS (which is maybe also necessary to work with it in R?).
So far I am able to read in the file with
hdf<- h5file("mypath/GDNBO-SVDNB_npp_d20171101_t0110370_e0116174_b31151_c20180208224859630066_nobc_ops.h5", mode = "r")
But I cannot figure out how to access the "radiance" band, let alone plot it. I have read the "h5" package documentation without any progress.
As another option I have tried to export the h5 file to geotiff with
sds <- get_subdatasets("subset_1_d20171101_t0110370.h5") gdal_translate(sds, dst_dataset = "radiance.tif", overwrite=T) #subset 17 is the radiance band i need
however the file has lost its geolocation during the transformation, when the geotiff is opened in e.g. QGIS, it does not have any location or projection.
I understand that the geolocation is stored in separate bands (latitude, longitude) however I don't understand how I can access meta data on the corner coordinates and the projection, and then pass this on to gdal_translate() or a software like ArcGIS?
Anyone knows how to deal with these type of files in R?
I seek an example in R how to plot or export this data file.