I'm trying to use the snow
and snowfall
packages, specifically the sfSapply()
function to extract data from multiple raster files. It looks something like this:
queue <- list(rast1, rast2, rast3)
sfInit(parallel=TRUE, cpus=3)
sfLibrary(raster)
sfLibrary(rgdal)
sfLibrary(sp)
a <- sfSapply(queue, extract, sp=TRUE, fun=mean, y=tracts)
sfStop()
The fun
argument passed to sfSapply()
is intended for the extract()
function (in the raster
library). However, sfSapply()
also takes a fun
argument (extract()
); in this example, I've provided it as the second positional argument.
How can I specify a fun
argument for the passed function and not have it confused with the fun
argument expected by sfSapply()
?