I have three raster
in a list
.
rasterlist <- (r1, r2, r3)
I have one operation to combine each raster with another - let's say add them.
How do I write a loop
which combines all the rasters iteratively?
Like this:
result1 <- r1+r2
result2 <- r2+r3
result3 <- r1+r3
Note: My operation within {}
is around 200 lines long and not a simple addition, which is why I need a nice loop around.
我们可以使用combn
来获取list
元素的组合并求和
combn(rasterlist, 2, FUN = function(x) x[1] + x[2])
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.