Robert J. Hijmans | 1 Jun 2012 07:02
Picon

Re: Raster package: list vs arrays for creating a raster brick

Jonathan,

Thanks for the useful example. In the development version of raster
(1.9-98) I now get more reasonable results:

> system.time(A <- brick(A))
   user  system elapsed
   1.45    0.32    1.78
>
> system.time(L <- brick(L))
   user  system elapsed
   2.50    0.34    2.87
>

Robert

On Thu, May 31, 2012 at 10:14 AM, Jonathan Kennel <j2kennel <at> gmail.com>wrote:

> Hello,
>
> I came across an interesting phenomenon when dealing with a large number of
> rasters sets (~1300 with each one being 250x250).  What happened was that I
> was unable to create the brick using a list of rasters due to time
> constraints whereas when creating a brick from an 3D array the
> solution comparatively was lightning fast.  Here is an example:
>
> library(raster)
>
> library(raster)
> V <- rnorm(5000000)
> A <- array(V, c(100,100,500))
>
> L <- unlist(apply(A, 3, list), recursive = FALSE)
> L <- lapply(L, raster)
>
> system.time(A <- brick(A))
> #   user  system elapsed
> #   0.48    0.10    0.58
>
> system.time(L <- brick(L))
> #   user  system elapsed
> #  44.80    0.22   46.21
>
> Is this huge speed difference the expected result or am I missing
> something?
>
> Thank you,
> -Jonathan
>
>        [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo <at> r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

	[[alternative HTML version deleted]]

Gmane