我有一个称为RCP1pctCO2Median的RasterStack对象,并希望提取海洋区域中一系列网格单元的值。我想在整个网格单元中求平均值
RCP1pctCO2Median看起来像这样:
class : RasterStack
dimensions : 64, 128, 8192, 138 (nrow, ncol, ncell, nlayers)
resolution : 2.8125, 2.789327 (x, y)
extent : -181.4062, 178.5938, -89.25846, 89.25846 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0
names : layer.1, layer.2, layer.3, layer.4, layer.5, layer.6, layer.7,
layer.8, layer.9, layer.10, layer.11, layer.12, layer.13, layer.14, layer.15, ...
min values : 0.42964514, 0.43375653, 0.51749371, 0.50838983, 0.45366730, 0.53099146, 0.49757186,
0.45697752, 0.41382199, 0.46082401, 0.45516687, 0.51857087, 0.41005131, 0.45956529, 0.47497867, ...
max values : 96.30350, 104.08584, 88.92751, 97.49373, 89.57201, 90.58570, 86.67651,
88.33519, 96.94720, 101.58247, 96.07792, 93.21948, 99.59785, 94.26218, 90.62138, ...
我尝试使用wrld_simpl指定以下经度和纬度范围:
data("wrld_simpl")
b <- wrld_simpl
ext <- extent(c(-120, -100, -10, 10)) #specifies a range of longitudes and latitudes
g <- (RCP1pctCO2Median, ext)
但是,我收到以下错误:
Error in as.integer(round(y)) :
cannot coerce type 'S4' to vector of type 'integer'
为什么会发生此错误?
我知道wrld_simpl可以捕获特定的国家,但是我也对孤立的海洋中的特定区域感兴趣。除非有可能使用wrld_simpl捕获海洋区域?