[英]How can I add more raster to a stack of raster that already has some raster files in R?
I have a raster stack named rstack
:我有一个名为
rstack
的光栅堆栈:
rstack <- list.files(path) #path contains the location of the directory
Now I have another raster file named araster
.现在我有另一个名为
araster
光栅文件。
How do I add this new raster araster
into the stack rstack
?如何将这个新的栅格
araster
添加到堆栈rstack
?
I have spent a lot of time searching for this online but to no avail.我花了很多时间在网上搜索这个,但无济于事。
You can use the addLayer
function to add new raster files to an existing stack.您可以使用
addLayer
函数将新光栅文件添加到现有堆栈中。
library(raster)
rstack <- addLayer(rstack,araster)
Not sure if I'm following your question correctly, but f you are merely want to combine both stacks, it should simply work with c
.不确定我是否正确地关注了您的问题,但是如果您只是想将两个堆栈结合起来,它应该只与
c
。
rstack <- list.files()
newstack <- list.files()
combined_stack <- c(rstack, newstack)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.