Skip to content

Problem with using multicore resample in Raster package

3 messages · Bastien.Ferland-Raymond at mffp.gouv.qc.ca, Michael Treglia, Robert J. Hijmans

#
Dear all,

I wrote a code last year that was running well.  I've retried the same code this month and it's not working anymore.  The problem arise from using cluster to do resampling in the raster package on multiple threads.  I've tried on two computers, both have the problem.

Here is a reproducible example :

###

library(raster)
#Loading required package: sp
 ## prepare the test rasters
r1 <- raster(nrows=1000, ncols=1000, xmn=0, xmx=1000)
set.seed(123)
values(r1) <- round(rnorm(1000000,100,20))
r2 <- raster(nrows=1000, ncols=1000, xmn=.2, xmx=1000.2)
 ## testing resample without multicore
resamp.single <- resample(r1, r2)
 ## testing resample with multicore
beginCluster(11)
#Loading required namespace: snow
resamp.multi <- resample(r1, r2)
#Using cluster with 11 nodes
#Error in UseMethod("recvOneData") :
# no applicable method for 'recvOneData' applied to an object of class "c('SOCKcluster', 'cluster')"
endCluster()
#Error in UseMethod("stopCluster") :
# no applicable method for 'stopCluster' applied to an object of class "c('SOCKcluster', 'cluster')"
 sessionInfo()
#R version 3.1.2 (2014-10-31)
#Platform: x86_64-w64-mingw32/x64 (64-bit)

#locale:
#[1] LC_COLLATE=French_Canada.1252  LC_CTYPE=French_Canada.1252
#[3] LC_MONETARY=French_Canada.1252 LC_NUMERIC=C
#[5] LC_TIME=French_Canada.1252

#attached base packages:
#[1] stats     graphics  grDevices utils     datasets  methods   base

#other attached packages:
#[1] raster_2.3-24 sp_1.0-17

#loaded via a namespace (and not attached):
#[1] grid_3.1.2      lattice_0.20-30 snow_0.3-13


Any idea what the problem is?

Thanks

Bastien Ferland-Raymond, M.Sc. Stat., M.Sc. Biol.
Division des orientations et projets sp?ciaux
Direction des inventaires forestiers
Minist?re des For?ts, de la Faune et des Parcs
#
Haven't tried to troubleshoot the problem, but your code works fine for me.

Looks like I'm running a slightly older versions of packages (notably, for
raster). My session info is below.  Here's my session info in case it helps:

R version 3.1.2 (2014-10-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] snow_0.3-13   raster_2.2-31 sp_1.0-15

loaded via a namespace (and not attached):
[1] grid_3.1.2      lattice_0.20-29

-Mike T

On Fri, Feb 27, 2015 at 8:26 AM, <Bastien.Ferland-Raymond at mffp.gouv.qc.ca>
wrote:

  
  
#
Bastien,

This arises from a change in CRAN policy (the requirement to use
"requireNamespace" instead of "require") which somehow creates a
problem for snow::recvOneData. This is all a bit mysterious to me. The
development version uses require again for the snow package such that
things work as they should. Please use that version for now:

install.packages("raster", repos="http://R-Forge.R-project.org")

Robert



On Fri, Feb 27, 2015 at 6:26 AM,
<Bastien.Ferland-Raymond at mffp.gouv.qc.ca> wrote: