如何循环浏览HDF5文件并将我想要的数据提取到.CSV中?
我有兴趣从HDF5文件中提取LIDAR数据。 每个HDF5文件具有8个梁(基本上是8个单独的数据集),我有38个HDF5文件。 我已经使用以下代码从一个光束中提取感兴趣的数据:
file_one = "D:/GEDI_Thesis_Data/L2A/56143-1/2432389212/processed_GEDI02_A_2019121080625_O02166_02_T05019_02_003_01_V002.h5"
tmp = h5ls(file_one)
beam = h5read(file_one, "/BEAM0000/beam")
lon = h5read(file_one, "/BEAM0000/lon_lowestmode")
lat = h5read(file_one, "/BEAM0000/lat_lowestmode")
sht_numb = h5read(file_one, "/BEAM0000/shot_number",
bit64conversion='bit64')
sht_numb = paste0(sht_numb)
qlty_fl = h5read(file_one, "/BEAM0000/quality_flag")
dgrd_fl = h5read(file_one, "/BEAM0000/degrade_flag")
delt_tm = h5read(file_one, "/BEAM0000/delta_time")
snstvty = h5read(file_one, "/BEAM0000/sensitivity")
slr_lvt = h5read(file_one, "/BEAM0000/solar_elevation")
elv_hgh = h5read(file_one, "/BEAM0000/elev_highestreturn")
elv_lws = h5read(file_one, "/BEAM0000/elev_lowestmode")
rh = h5read(file_one, "BEAM0000/rh")
rh = as.data.frame(t(rh))
colnames(rh) = paste0('rh', 0:100)
T05019_BEAM0000 = cbind(beam, lon, lat, sht_numb, dgrd_fl, qlty_fl, delt_tm, snstvty, slr_lvt, elv_hgh, elv_lws, rh)
write.csv(T05019_BEAM0000, paste0(sht_numb), "D:/GEDI_Thesis_Data/L2A_csvfiles/T05019_BEAM0000.csv")
现在,我非常想避免为每个HDF5文件中的所有光束重复300次此代码。 有没有办法循环浏览每个文件并在一个表中提取我需要的东西?
在Rstudio锻炼,
感谢您的任何帮助。
I am interested in extracting lidar data from HDF5 files.
Each HDF5 file has 8 beams (essentially 8 separate datasets), and I have 38 HDF5 files.
I have used the following code to extract the data of interest from one beam:
file_one = "D:/GEDI_Thesis_Data/L2A/56143-1/2432389212/processed_GEDI02_A_2019121080625_O02166_02_T05019_02_003_01_V002.h5"
tmp = h5ls(file_one)
beam = h5read(file_one, "/BEAM0000/beam")
lon = h5read(file_one, "/BEAM0000/lon_lowestmode")
lat = h5read(file_one, "/BEAM0000/lat_lowestmode")
sht_numb = h5read(file_one, "/BEAM0000/shot_number",
bit64conversion='bit64')
sht_numb = paste0(sht_numb)
qlty_fl = h5read(file_one, "/BEAM0000/quality_flag")
dgrd_fl = h5read(file_one, "/BEAM0000/degrade_flag")
delt_tm = h5read(file_one, "/BEAM0000/delta_time")
snstvty = h5read(file_one, "/BEAM0000/sensitivity")
slr_lvt = h5read(file_one, "/BEAM0000/solar_elevation")
elv_hgh = h5read(file_one, "/BEAM0000/elev_highestreturn")
elv_lws = h5read(file_one, "/BEAM0000/elev_lowestmode")
rh = h5read(file_one, "BEAM0000/rh")
rh = as.data.frame(t(rh))
colnames(rh) = paste0('rh', 0:100)
T05019_BEAM0000 = cbind(beam, lon, lat, sht_numb, dgrd_fl, qlty_fl, delt_tm, snstvty, slr_lvt, elv_hgh, elv_lws, rh)
write.csv(T05019_BEAM0000, paste0(sht_numb), "D:/GEDI_Thesis_Data/L2A_csvfiles/T05019_BEAM0000.csv")
Now I would very much like to avoid repeating this code over 300 times for all of the beams in every HDF5 file.
Is there a way to loop through each file and extract what I need in one table?
Working out of RStudio
Thanks for any help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论