[R-sig-Geo] convert owin object to SpatialPolygons object (write buffered MCP to shapefile)

Adrian Baddeley adrian at maths.uwa.edu.au
Wed May 20 03:51:09 CEST 2009


Tyler Dean Rudolph writes:

> I'd like to create a buffered minimum convex polygon around a set of points and write the buffered polygon to a shapefile. 
> I have two columns, x and y, for the geographic locations.  I can use convexhull.xy in spatstat to create the MCP as 
> an owin, then use dilate.owin to enlarge the window, but how can I now convert the owin (or im) object into a 
> SpatialPolygons object in order to write it to a shapefile?  

Take the convex hull of the boundary pixels:
          convexhull.xy(vertices(dilate.owin(convex.hull(ORIGINALDATA), RADIUS)))

This converts it to a polygonal owin object which you can then convert to a SpatialPolygons object using as(). 

Alternatively if you want the buffered region to have the same shape as the convex hull, so that the buffer is a "scalar dilation" i.e. simply an enlarged version of the convex hull, then use the function 'ripras'. In spatstat 1.15-3 and later, you can control the enlargement factor.

Adrian Baddeley



More information about the R-sig-Geo mailing list