我正在研究多波段光栅图像。对于处理,将Raster转换为矩阵,然后进行像素处理。我在将像素值写入空白3d数组时遇到问题,如下所述。
让我们假设
我有一个空白3D array
x = array(0,c(4,5,3))
x
, , 1
[,1] [,2] [,3] [,4] [,5]
[1,] 0 0 0 0 0
[2,] 0 0 0 0 0
[3,] 0 0 0 0 0
[4,] 0 0 0 0 0
, , 2
[,1] [,2] [,3] [,4] [,5]
[1,] 0 0 0 0 0
[2,] 0 0 0 0 0
[3,] 0 0 0 0 0
[4,] 0 0 0 0 0
, , 3
[,1] [,2] [,3] [,4] [,5]
[1,] 0 0 0 0 0
[2,] 0 0 0 0 0
[3,] 0 0 0 0 0
[4,] 0 0 0 0 0
和vector
y = c(5,14)
我想在y
中复制3rd dimension of x
的值,以便输出看起来如下所示
x
, , 1
[,1] [,2] [,3] [,4] [,5]
[1,] 5 0 0 0 0
[2,] 0 0 0 0 0
[3,] 0 0 0 0 0
[4,] 0 0 0 0 0
, , 2
[,1] [,2] [,3] [,4] [,5]
[1,] 14 0 0 0 0
[2,] 0 0 0 0 0
[3,] 0 0 0 0 0
[4,] 0 0 0 0 0
, , 3
[,1] [,2] [,3] [,4] [,5]
[1,] NA 0 0 0 0
[2,] 0 0 0 0 0
[3,] 0 0 0 0 0
[4,] 0 0 0 0 0
我在互联网上搜索过,但我找不到任何解决方案。