Skip to content
Prev 26720 / 29559 Next

raster::overlay with a function that calls a list of vectors

Hi Hugo

Vectorize() sometimes solves this issue.

foo <- function(x,y,...) {return(rbinom(n=1, size=1, prob=probs[[y]][x]))}
fooV <- Vectorize(foo)

Using your toy example, check carefully if

o <- overlay(r1,r2,fun = fooV)

gives you what you are looking for.

HTH
Rafael
--
Rafael W?est Karpati
http://www.rowueest.net