Dear list,

I once again seek your advice in understanding the following.
makeDistances is a function I feed to foreach. The computation intensive
part is done by a second function calcDistance.

    # Run in parallel
    makeDistances <- function(xy, rst, effect.distance, cnt, num.points) {
        source("d:/workspace/Texas Ranger/calcDistance.R")
        for (j in 1:num.points) {
            file.name <- paste("walker", cnt, "_", j, sep = "")
            clc <- calcDistance(object = rst, origin.point = xy[j,],
                      effect.distance = effect.distance)
            writeRaster(clc, file.name, overwrite = TRUE)
        }
    }

    foreach(xy = xy.list, cnt = icount()) %do%
       makeDistances(xy, rst = rst, effect.distance = effect.distance,
       cnt, num.points = dim(xy.list[[cnt]])[1])

When I run makeDistances via %do% things work out fine, but I'm unable to
run via %dopar%. The following error is returned:

Error in makeDistances(xy, rst = rst, effect.distance = effect.distance,  :
  task 1 failed - "object 'effect.distance' not found"


It seems like a scoping issue, however I failed to comprehend how to feed
the argument to the function to make it work. Any advice will be much
appreciated.


Cheers,
Roman

-- 
In God we trust, all others bring data.

	[[alternative HTML version deleted]]

