我有这 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)
任何帮助将不胜感激。
谢谢
答案 0 :(得分:2)
我不知道这是否真的有效,因为我不是 raster
或导入 hdf
文件的专家。但是这段代码确实为我加载了 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
答案 1 :(得分:0)