[R-sig-Geo] subs (raster) on large dataset

Robert Hijmans r.hijmans at gmail.com
Thu Apr 14 19:43:52 CEST 2011


Lyndon,

I have no idea what might be causing this. I would suggest to track down
where exactly this happens, by going, line by line, through the code of
'subs' 

getMethod("subs", c("RasterLayer", "data.frame"))

Presumably, something is not moving here:

for (i in 1:tr$n) {
     v <- getValues(x, row = tr$row[i], nrows = tr$size)
     r <- writeValues(r, localmerge(v, y, subsWithNA),  tr$row[i])
     pbStep(pb)
}

so you can try

 i <- 1
 v <- getValues(x, row = tr$row[i], nrows = tr$size)
 x <- localmerge(v, y, subsWithNA)

and if that last step is indeed very slow, have a step by step look at
"localmerge". 

You can then also see of it matters if you make changes to the "chunksize"
and "maxmemory" options ?setOptions. These will affect the size of "v" in
the code above, and perhaps there is a non-linear effect on the performance
of merge. 

Robert


--
View this message in context: http://r-sig-geo.2731867.n2.nabble.com/subs-raster-on-large-dataset-tp6272926p6273741.html
Sent from the R-sig-geo mailing list archive at Nabble.com.



More information about the R-sig-Geo mailing list