1

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

https://github.com/NEONScience/NEON-Data-Skills/blob/master/tutorials-in-development/R/R-RS-data-institute/hyperspectral/subset-h5-file-R.Rmd

# 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
MNewco
  • 13
  • 4
  • You got results in `coordInfo`. Can you be more specific about what you are expecting? – IRTFM Jul 28 '18 at 22:08
  • The `coordInfo` provides the origin, but I am unsure what to do with that information. Ideally I would like to have a raster of `datSWE` that is projected. Currently `datSWE` is just a data.frame. Maybe a better way to ask the question is how to take `coordInfo` and use it to project my `datSWE` so that it is a projected raster. – MNewco Jul 30 '18 at 02:16
  • Edit your question to reflect that clarification. – IRTFM Jul 30 '18 at 03:36
  • Question edited for clarification. – MNewco Jul 30 '18 at 21:44

0 Answers0