I would like to project a data.frame from an h5 file into a projected raster. The h5 file I am using is a snow-water equivalent grid for the Sierra-Nevada, California, and the origin for the coordinates is in one of the sub-levels of the file. I cannot figure out how to create a projected raster grid using the origin. Below is my code that downloads the data and extracts the h5 file structure. I am using R with the rhdf5 library
How do I take the coordInfo and use it to project my datSWE so that it is a projected raster?
Here are some additional web links that I used to create this first section of code.
https://rpubs.com/fenclmar/98163
# Call the R HDF5 Library, install from BioConductor repo
library(rhdf5)
#download the data
theUrl<-"ftp://ftp.snow.ucsb.edu/pub/org/snow/products/reconstruction/sierra/reconstruction_sierra_500m_CY2001.h5"
theFile<-"reconstruction_sierra_500m_CY2001.h5"
try(curl::curl_download(theUrl, theFile, quiet=TRUE))
# View structure of file
f <- "reconstruction_sierra_500m_CY2001.h5"
h5ls(f)
#look at how many "levels" of nesting
h5ls(f,recursive=5)
fiu_struct <- h5ls(f,recursive=5)
# have a look at the structure.
fiu_struct
fiu_struct[3,1]
## Let's view the metadata for the coordinate info
coordInfo <- h5readAttributes(f,fiu_struct[3,1])
coordInfo
##Extract the snow water equivalent data
datSWE <- h5read(f, "Grid/swe")
str(datSWE)
day1<-datSWE[,,1] #extract first day of the time series grid