[R-sig-Geo] raster::stack() help
Robert J. Hijmans
r.hijmans at gmail.com
Wed Jul 31 05:29:36 CEST 2013
My guess is that there is another package hiding the raster function
-- no messages? You could explicitly use raster::stack()
Also, this avoids the call and might be more efficient:
library(raster)
a.list <- list()
for (yr in seq(2000,2008)){
....
a.layer = raster(something).
a.list <- c(a.list, a.layer)
}
a.stack = stack(a.list)
Robert
On Tue, Jul 30, 2013 at 7:14 PM, Andrew Vitale <vitale232 at gmail.com> wrote:
> Works on my machine.
>
>> a.stack <- stack()
>> a.stack
> class : RasterStack
> nlayers : 0
>
>> stack()
> class : RasterStack
> nlayers : 0
>
>> sessionInfo()
> R version 3.0.1 (2013-05-16)
> Platform: x86_64-w64-mingw32/x64 (64-bit)
>
> locale:
> [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United
> States.1252
> [3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
>
> [5] LC_TIME=English_United States.1252
>
> attached base packages:
> [1] grid stats graphics grDevices utils datasets methods
> base
>
> other attached packages:
> [1] ncdf_1.6.6 rasterVis_0.21 hexbin_1.26.2
> latticeExtra_0.6-24 RColorBrewer_1.0-5
> [6] lattice_0.20-15 rgdal_0.8-9 ncdf4_1.9
> raster_2.1-49 sp_1.0-11
>
> loaded via a namespace (and not attached):
> [1] tools_3.0.1 zoo_1.7-10
>>
>
>
> On Tue, Jul 30, 2013 at 10:14 AM, Dominik Schneider <
> Dominik.Schneider at colorado.edu> wrote:
>
>> Hi, I am trying to initialize an empty stack with
>>
>> require(raster)
>> a.stack <- stack()
>> for (yr in seq(2000,2008)){
>> ....
>> a.layer = raster(something).
>>
>> a.stack <- addLayer(a.stack, a.layer)
>> }
>>
>> Even if I just run a.stack <- stack() in the commandline:
>> > stack()
>> Error in as.list(x) : argument "x" is missing, with no default
>>
>> I know I've done this in the past and the help file for stack() says x can
>> be missing to create an empty stack. Could someone help me debug or suggest
>> a workaround?
>> Thanks
>> Dominik
>>
>> [[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
>>
>
>
>
> --
> *Andrew P. Vitale*
> Masters Student
> Department of Geography
> University of Nevada, Reno
> (412) 915-3632
> vitale232 at gmail.com
>
> [[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
More information about the R-sig-Geo
mailing list