With the raster package you could do:

library(raster)

# convert m to raster object for soil
r <-  raster(m[ , 'soil'])
r <- crop(r, extent(c(180000, 181560, 331000, 333760))

Best
Johannes


On Sat, Jun 22, 2013 at 3:24 PM, Mark Payne <markpayneatwork@gmail.com>wrote:

> Hi,
>
> This should be simple, but I simply can't find an "elegant" solution.
>
> I have a SpatialPixelsDataFrame that I would like to clip (crop) to a
> smaller object. For example,
>
> > data(meuse.grid)
> > m = SpatialPixelsDataFrame(points = meuse.grid[c("x", "y")], data =
> meuse.grid)
> >
> > bbox(m)
>      min    max
> x 178440 181560
> y 329600 333760
> >
>
> I would like to constrain m, to all y > 331000 and x >180000. What is
> the most efficient way to do this (and have the other functionality
> e.g bbox and plotting) reflect this reduced data set.
>
> Mark
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

	[[alternative HTML version deleted]]

