我试图从R中的一个特定NetCDF文件中提取所有级别,我可以手动地将每个级别提取为一行代码,然后将它们合并为一个数据框架。但是当我有很多文件的时候,这是很长的时间。是否可以在一个文件中提取所有43层?
我使用了这个如何使用光栅包从netcdf文件中提取所有级别?和用R中的级别绘制netcdf文件作为指导。
从本质上讲,硝酸盐数据来自
https://www.nodc.noaa.gov/cgi-bin/OC5/woa18/woa18oxnu.pl的浓度在43种不同深度。有可能提取特定地点的所有深度吗?
我可以这样做一个层次。但每一层代表一个深度。有可能得到所有级别的信息吗?
我也不明白第三个警告信息:在.getCRSfromGridMap4(atts)中:无法处理CRS: epsg_code=EPSG:4326的这些部分
我得到了一个不同的结果(1月1级为0.5),而我的同事在1月1级则为1.4 )。我的错误是由于上述警告吗?
#this works
Nit_Jan <- brick("~woa18_all_n01_01.nc", stopIfNotEqualSpaced =
FALSE, varname = "n_an", level = 1)
#this doesn't
Nit_Jan <- brick("~woa18_all_n01_01.nc", stopIfNotEqualSpaced =
FALSE, varname = "n_an", level = 1:43)
Warning messages:
1: In if (level <= 0) { :
the condition has length > 1 and only the first element will be used
2: In if (oldlevel != level) { :
the condition has length > 1 and only the first element will be used
3: In .getCRSfromGridMap4(atts) : cannot process these parts of the
CRS:epsg_code=EPSG:4326我想深入地绘制硝酸盐图。
发布于 2019-05-22 18:56:53
这里有些混乱,因为文件有“级别”(第四个维度),但是级别的数量是一个(所以没有第四个维度)。代码可能会检测到这一点,但现在您必须添加lvar=4才能获得所需的对象。
library(raster)
f <- "woa18_all_n01_01.nc"
b <- brick(f, var="n_oa", lvar=4)
b
#class : RasterBrick
#dimensions : 180, 360, 64800, 43 (nrow, ncol, ncell, nlayers)
#resolution : 1, 1 (x, y)
#extent : -180, 180, -90, 90 (xmin, xmax, ymin, ymax)
#crs : +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0
#source : woa18_all_n01_01.nc
#names : X0, X5, X10, X15, X20, X25, X30, X35, X40, X45, X50, X55, X60, X65, X70, ...
#meters : 0, 800 (min, max)
#varname : n_oa
#level : 1 现在你可以做了
pt <- cbind(121.5, 27.5)
e <- extract(b, pt)
e[1:5]
#[1] 10.43725 10.37617 10.23662 13.76292 13.65862警告#3
3:在.getCRSfromGridMap4(atts)中:无法处理CRS:epsg_code=EPSG:4326的这些部分
可以忽略,但我会在下一个版本中修复它。我觉得最好的办法是
crs(b) <- "+init=EPSG:4326"PS:光栅的开发版本现在表现得更好了:
f <- "woa18_all_n01_01.nc"
brick(f, var="n_oa")
#class : RasterBrick
#dimensions : 180, 360, 64800, 43 (nrow, ncol, ncell, nlayers)
#resolution : 1, 1 (x, y)
#extent : -180, 180, -90, 90 (xmin, xmax, ymin, ymax)
#crs : +init=EPSG:4326 +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0
#source : woa18_all_n01_01.nc
#names : X0, X5, X10, X15, X20, X25, X30, X35, X40, X45, X50, X55, X60, X65, X70, ...
#depth (meters): 0, 800 (min, max)
#varname : n_oa
#level : 1 https://stackoverflow.com/questions/56261199
复制相似问题