terra
terra copied to clipboard
Issue with cores argument when using lapp() on a SpatRasterDataset
I am trying to apply a custom function to two spatial rasters (about 10,000 layers each) that make up a spatial dataset. This works fine when I leave the cores argument as the default 1 (though it takes a long time to run) but when I try to up the number of cores >1, I get an error "Error in (function (r1, r2) : unused argument (cores = 2). When I use the cores argument with the app() function (using a dummy test function) on the same spatial dataset, everything works peachy.
In search of a solution, I was looking at the code for the app and lapp functions. I noticed this difference which I suspect might be leading to my issue.
In app();
setMethod("app", signature(x="SpatRasterDataset"), function(x, fun, ..., cores=1, filename="", overwrite=FALSE, wopt=list())
Versus in lapp() ;
setMethod("lapp", signature(x="SpatRasterDataset"), function(x, fun, ..., usenames=FALSE, recycle=FALSE, filename="", overwrite=FALSE, wopt=list())
I am just wondering if there is a reason for the lack of built in parallel processing with lapp() on spatial data sets, or if it was simply an oversight. Thank you so much for your work writing and maintaining this resource for all.
This is not an "issue" in the sense of the software not doing what it was designed to do. The feature is simply not available (and that is not an oversight). You are requesting a new feature (and that is fine).