Skip to content

question about stack command

2 messages · Michela Giusti, Edzer Pebesma

#
Hello everybody,

I have many "SpatialPixelsDataFrame" in my R project and I am wondering 
if there is a command like the command "stack" for raster to do the same 
with this object class.
Can you help me?
Thank you.
Bye,

Michela
#
Michela,

there are options that come fairly close:

What you could do is add columns to a SpatialPixelsDataFrame:

a$colb = b$col
a$colc = c$col

but of course you need to check yourself that this make sense (i.e. the
pixels of a, b and c are identical).

Another way would be working with SpatialGridDataFrame's:

fullgrid(a) = TRUE
fullgrid(b) = TRUE
fullgrid(c) = TRUE

abc = cbind(a,b,c)

which combines layers into one object (similar to what raster::stack
does), and does check for equality of all grid topologies.

Best regards,
On 12/04/2012 11:34 AM, Michela Giusti wrote: