[R-sig-Geo] Error in clusterR

Jonathan Greenberg jgrn at illinois.edu
Tue May 13 18:30:27 CEST 2014


Srinivas:

Can you explain, more generally, what you are trying to accomplish?
It seems like you are just trying to get a list-of-dataframes from the
MODIS pixels.  It might be easier to do something like this with the
package "foreach".  Keep in mind reading/write is often I/O limited,
so you may not see any performance gain reading in parallel.

I'd also recommend looking at "rasterEngine" in my spatial.tools
package.  Here's a tutorial on how to use it:

http://publish.illinois.edu/jgrn/software-and-datasets/rasterengine-tutorial/

--j

On Tue, May 13, 2014 at 5:11 AM, Srinivas V <srinivasv at feralindia.org> wrote:
> Hi,
>
> I wrote a code which uses clusterR to run a function on multiple CPUs to
> process MODIS 16 day dataset. The function converts a brick to dataframe.
> The existing commands to do this in package raster is very slow on large
> datasets, therefore I'm attempting to use the multicore option to speed up
> the process.
>
> I get the following error
> Error in clusterR(n1, qckextract) : cluster error
>
> I would appreciate your advice on to fix the function. Thanks!
>
>
> library(raster)
>
> n1<-brick("ndvih25v08masked.grd")
>
> beginCluster(nice=20)
> nodes <- length(getCluster())
> bs <- blockSize(n1, minblocks=nodes*4)
>
> qckextract <- function(i) {
>   for (i in 1:length(bs$n)) {
>     e<- extent(xmin(x), xmax(x), yFromRow(x, bs$row[i]+bs$nrows[i]-1) - 0.5
> * yres(x), yFromRow(x, bs$row[i])+0.5 * yres(x))
>     n <- cellsFromExtent(x,e)
>     v <- (getValues(x, bs$row[i], bs$nrows[i]))/10000
>     v<-as.data.frame(v)
>     v<- as.data.frame(cbind(n,v))
>   }
>   return(v)
> }
>
> nx<-clusterR(n1,qckextract)
> endCluster()
>
> --
>
> Srinivas Vaidyanathan
> Senior Research Fellow
> Foundation for Ecological Research, Advocacy & Learning
> India.
>
> Web:www.feralindia.org
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo



-- 
Jonathan A. Greenberg, PhD
Assistant Professor
Global Environmental Analysis and Remote Sensing (GEARS) Laboratory
Department of Geography and Geographic Information Science
University of Illinois at Urbana-Champaign
259 Computing Applications Building, MC-150
605 East Springfield Avenue
Champaign, IL  61820-6371
Phone: 217-300-1924
http://www.geog.illinois.edu/~jgrn/
AIM: jgrn307, MSN: jgrn307 at hotmail.com, Gchat: jgrn307, Skype: jgrn3007



More information about the R-sig-Geo mailing list