简体   繁体   中英

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 <- list.files(path) #path contains the location of the directory 

Now I have another raster file named araster .

How do I add this new raster araster into the stack 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.

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 .

rstack   <- list.files()
newstack <- list.files()

combined_stack <- c(rstack, newstack)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM