[R-sig-Geo] drop layer/band from SpatialGridDataFrame

Andy Bunn Andy.Bunn at wwu.edu
Tue Aug 10 21:02:02 CEST 2010


> -----Original Message-----
> From: Michael Sumner [mailto:mdsumner at gmail.com]
> Sent: Monday, August 09, 2010 11:28 PM
> To: Andy Bunn
> Cc: r-sig-geo at stat.math.ethz.ch
> Subject: Re: [R-sig-Geo] drop layer/band from SpatialGridDataFrame
> 
> Do you mean "layer" as in the first column in the data.frame?
> 
> Does this do what you want?  The negative index means "everything but
> these indexes".
> 
> monthly.sp <- monthly.sp[,-1]

I was a bit hasty. The SpatialGridDataFrame contains 325 separate grids each with 155 cols and 52 rows. E.g., if it were an array I'd think it would have dimensions of 52, 155, 325 and I'd want to do something like: monthly.sp[,,-1]. When I'm done I want the object to have 324 variables with 8060 obs and keep the cells.dim at 155 by 52.


> 
> 
> 
> On Tue, Aug 10, 2010 at 12:40 PM, Andy Bunn <Andy.Bunn at wwu.edu> wrote:
> > I have a SpatialGridDataFrame with 325 variables in the @ data slot.
> I want to drop the first layer. Seems simple enough. Any help? Thanks,
> Andy
> >
> >> str(monthly.sp)
> > Formal class 'SpatialGridDataFrame' [package "sp"] with 6 slots
> >  ..@ data       :'data.frame': 8060 obs. of  325 variables:
> >  .. ..$ values: num [1:8060] 127.5 31.9 127.5 127.5 231.1 ...
> >  .. ..$ values: num [1:8060] 127.5 31.9 127.5 127.5 231.1 ...
> >  .. and so on
> >
> > _______________________________________________
> > R-sig-Geo mailing list
> > R-sig-Geo at stat.math.ethz.ch
> > https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> >
> 
> 
> 
> --
> Michael Sumner
> Institute for Marine and Antarctic Studies, University of Tasmania
> Hobart, Australia
> e-mail: mdsumner at gmail.com



More information about the R-sig-Geo mailing list