[R-sig-Geo] spatial time series

Andy Bunn Andy.Bunn at wwu.edu
Mon Jun 6 18:31:06 CEST 2011


> > Now what I want to do is to do the same with every single pixel and
> get
> > a
> > gridded result. What is the best appoach to start with? Is there a
> way
> > to
> > create a time series with my brick or SpatialGidDataframe? Beside
> this
> > example there are also other things I want to do with my rasters
> which
> > call
> > for a "ts" class object, but I don't know where to start and I'd be
> > thankful
> > for any hints...
> >
> 
When I have to do this kind of thing I take my stack and turn it into
an array. Then I write a function to do what I want and apply that
function over the array. Then remake the raster. Something like:

    bar <- as.array(my.raster.stack)
    foo <- apply(bar,c(1,2),function(x) {
        stuff(x)
        })
    foo <- raster(foo)
    extent(foo) <- extent(my.raster.stack)
    projection(foo) <- projection(my.raster.stack)

I'm sure there are other/better ways but this works pretty well for
what I do.



More information about the R-sig-Geo mailing list