HDFS 从多个hdf文件中提取变量

kmb7vmvb  于 2022-12-09  发布在  HDFS
关注(0)|答案(2)|浏览(223)

我有这3个文件here。试图堆叠它们,并提取一个名为“OzoneTropColumn”的变量。我能够提取单个文件的数据,但无法提取多个文件。

library(raster)
library(ncdf4)
list_col1 <- list.files("E:/TES", pattern = "*.hdf", full.names = TRUE) 
ncin1 <- raster::stack(list_col1, varname = "Data Fields/OzoneTropColumn", ncdf=TRUE)

任何帮助都将不胜感激。
谢谢你

vddsk6oq

vddsk6oq1#

我不知道这是否真的工作,因为我不是raster或导入hdf文件的Maven。但这段代码确实为我加载了R中的三个文件,但仍然给出了一些警告:-

library(raster)
library(ncdf4)
list_col1 <- as.list(list.files("E:/TES", pattern = "*.hdf",
                                full.names = TRUE))
ncin1 <- raster::stack(list_col1,
                       varname = "Data Fields/OzoneTropColumn",
                       ncdf=TRUE)

[1] "vobjtovarid4: **** WARNING **** I was asked to get a varid for dimension named Data Fields/phony_dim_1 BUT this dimension HAS NO DIMVAR! Code will probably fail at this point"
[1] "vobjtovarid4: **** WARNING **** I was asked to get a varid for dimension named Data Fields/phony_dim_0 BUT this dimension HAS NO DIMVAR! Code will probably fail at this point"
[1] "vobjtovarid4: **** WARNING **** I was asked to get a varid for dimension named Data Fields/phony_dim_1 BUT this dimension HAS NO DIMVAR! Code will probably fail at this point"
[1] "vobjtovarid4: **** WARNING **** I was asked to get a varid for dimension named Data Fields/phony_dim_0 BUT this dimension HAS NO DIMVAR! Code will probably fail at this point"
[1] "vobjtovarid4: **** WARNING **** I was asked to get a varid for dimension named Data Fields/phony_dim_1 BUT this dimension HAS NO DIMVAR! Code will probably fail at this point"
[1] "vobjtovarid4: **** WARNING **** I was asked to get a varid for dimension named Data Fields/phony_dim_0 BUT this dimension HAS NO DIMVAR! Code will probably fail at this point"
[1] "vobjtovarid4: **** WARNING **** I was asked to get a varid for dimension named Data Fields/phony_dim_1 BUT this dimension HAS NO DIMVAR! Code will probably fail at this point"
[1] "vobjtovarid4: **** WARNING **** I was asked to get a varid for dimension named Data Fields/phony_dim_0 BUT this dimension HAS NO DIMVAR! Code will probably fail at this point"

但是它显示它已经读取了3个文件

ncin1[[1]]
class      : RasterLayer 
dimensions : 83, 90, 7470  (nrow, ncol, ncell)
resolution : 1, 1  (x, y)
extent     : 0.5, 90.5, 0.5, 83.5  (xmin, xmax, ymin, ymax)
crs        : NA 
source     : /home/shawn/Downloads/TES/TES-Aura_L3-O3-M2004m09_F01_12.hdf 
names      : Data.Fields.OzoneTropColumn.1 
zvar       : Data Fields/OzoneTropColumn

ncin1[[2]]
class      : RasterLayer 
dimensions : 83, 90, 7470  (nrow, ncol, ncell)
resolution : 1, 1  (x, y)
extent     : 0.5, 90.5, 0.5, 83.5  (xmin, xmax, ymin, ymax)
crs        : NA 
source     : /home/shawn/Downloads/TES/TES-Aura_L3-O3-M2004m10_F01_12.hdf 
names      : Data.Fields.OzoneTropColumn.2 
zvar       : Data Fields/OzoneTropColumn

ncin1[[3]]
class      : RasterLayer 
dimensions : 83, 90, 7470  (nrow, ncol, ncell)
resolution : 1, 1  (x, y)
extent     : 0.5, 90.5, 0.5, 83.5  (xmin, xmax, ymin, ymax)
crs        : NA 
source     : /home/shawn/Downloads/TES/TES-Aura_L3-O3-M2004m11_F01_12.hdf 
names      : Data.Fields.OzoneTropColumn.3 
zvar       : Data Fields/OzoneTropColumn
pxq42qpu

pxq42qpu2#

Robert发布的脚本运行良好,唯一的区别是使用as.list和不使用as.list] 1 ] 1。我在不使用as. list之前尝试过。由于未知原因,提取的数据丢失了其地理参考

。因此不得不在栅格堆叠后给予范围和投影。谢谢Robert。

相关问题