![](/img/trans.png)
[英]The raster overlay function in R produces incorrect values for raster bricks
[英]r raster Can I combine two raster bricks directly?
我想組合兩個(或更多)光柵磚。 這是我想要做的一個例子
library(raster)
r <- raster(ncol=40, nrow=20)
r[] <- rnorm(n=ncell(r))
b1 <- brick(x=c(r, r*2, r))
b2 <- brick(x=c(r, r*3, r))
b <- brick(b1, b2)
此示例返回以下錯誤。
Error in (function (cl, name, valueClass) : assignment of an object of class “RasterBrick” is not valid for @'nlayers' in an object of class “.MultipleRasterData”; is(value, "integer") is not TRUE
如果我按如下方式創建堆棧而不是磚塊
b1 <- stack(x=c(r, r*2, r))
b2 <- stack(x=c(r, r*3, r))
b <- brick(b1, b2)
我收到以下錯誤消息
Error in if (values) { : argument is not interpretable as logical
您需要使用stack
將具有相同范圍和分辨率的多個柵格、堆棧或磚塊組合成一個多層對象。 然后你可以轉換成brick
s <- stack(b1, b2)
nlayers(s)
#[1] 6
b <- brick(s)
print(b)
class : RasterBrick
dimensions : 20, 40, 800, 6 (nrow, ncol, ncell, nlayers)
resolution : 9, 9 (x, y)
extent : -180, 180, -90, 90 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0
data source : in memory
names : layer.1.1, layer.2.1, layer.3.1, layer.1.2, layer.2.2, layer.3.2
min values : -3.604523, -7.209047, -3.604523, -3.604523, -10.813570, -3.604523
max values : 3.441872, 6.883743, 3.441872, 3.441872, 10.325615, 3.441872
有關更多信息,請參閱https://www.rspatial.org/raster/spatial/4-rasterdata.html#rasterstack-and-rasterbrick
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.