Learn R Programming

polyCub (version 0.2-0)

coerce-methods: Polygon Coercion Between Different Spatial Classes

Description

Different packages concerned with spatial data use different polygon specifications. The package polyCub offers S4-style coerce-methods to convert "Polygons" of the sp package, and "owin" objects of the spatstat package to and from the "gpc.poly" class of the rgeos package (originally from gpclib), as well as from "Polygon" to "gpc.poly". Note that conversions from and to the "owin" class are also available as functions owin2gpc and gpc2owin in package spatstat, and conversions from and to the "SpatialPolygons" class are included in the rgeos package. Furthermore, the (internal) xylist methods break down (convert) polygons from these classes to their core feature, a list of vertex coordinates.

Usage

xylist(object, ...)

## S3 method for class 'owin': xylist(object, ...)

## S3 method for class 'gpc.poly': xylist(object, ...)

## S3 method for class 'SpatialPolygons': xylist(object, ...)

## S3 method for class 'Polygons': xylist(object, ...)

## S3 method for class 'Polygon': xylist(object, ...)

## S3 method for class 'default': xylist(object, ...)

Arguments

object
an object of one of the supported spatial classes.
...
(unused) argument of the generic.

Value

  • Applying xylist to a polygon object, one gets a simple list, where each component (polygon) is a list of "x" and "y" coordinates, which give the coordinates of the vertices of the polygon following spatstat's "owin" convention (anticlockwise order without repeating any vertex). Additional elements like "area" and "hole" in each component are retained. The (somehow useless) default xylist-method does not perform any transformation but only checks that the polygons are not closed (first vertex not repeated).

describe

  • sp:Repeat first vertex at the end (closed), anticlockwise = hole, clockwise = normal boundary
  • spatstat:do not repeat first vertex, anticlockwise = normal boundary, clockwise = hole. This convention is also used in xylist.
  • gpclib:Unfortunately, there seems to be no convention for the specification of polygons of class "gpc.poly". The coerce-methods defined here produce vertices ordered according to the sp convention, i.e. clockwise for normal boundaries and anticlockwise for holes; however, the first vertex is not repeated!

Details

Different packages concerned with spatial data use different polygon specifications with respect to:
  • do we repeat the first vertex?
which direction represents holes?