1

我想将 h5 文件中的 data.frame 投影到投影栅格中。我使用的 h5 文件是加利福尼亚州内华达山脉的雪水等效网格,坐标的原点位于文件的子级别之一中。我无法弄清楚如何使用原点创建投影栅格网格。下面是我下载数​​据并提取 h5 文件结构的代码。我将 R 与 rhdf5 库一起使用

如何获取 coordInfo 并使用它来投影我的 datSWE,使其成为投影栅格?

以下是我用来创建第一部分代码的一些附加 Web 链接。

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
4

0 回答 0