[R-sig-Geo] (no subject)

Andy Bunn abunn at whrc.org
Thu Apr 6 22:38:09 CEST 2006


List,

I want to clip (subset) an sp object SpatialGridDataFrame using a polygon.
For instance in this example I want to create a new object of class
SpatialGridDataFrame that is clipped to the area inside the polygon on the
map.

  data(meuse.grid)
  coordinates(meuse.grid) <- ~x+y
  gridded(meuse.grid) <- T
  x = as(meuse.grid, "SpatialGridDataFrame")
  clip <- cbind(x=c(180000,180000,180500,180500,180000),
                y=c(330500,331000,331000,330500,330500))
  image(x, "dist")
  polygon(clip)
  # y = x[...clip?]


How can I go about it?

Thanks in advance, Andy




More information about the R-sig-Geo mailing list