Learn R Programming

polyCub (version 0.4-2)

xylist: Convert Various Polygon Classes to a Simple List of Vertices

Description

Different packages concerned with spatial data use different polygon specifications, which sometimes becomes very confusing (see Details below). To be compatible with the various polygon classes, package polyCub uses an S3 class "xylist", which represents polygons by their core feature only, a list of lists of vertex coordinates (see the "Value" section below). The generic function xylist can deal with the following polygon classes:
  • "owin"from packagespatstat
"gpc.poly" from package rgeos (or gpclib) "Polygons" from package sp (as well as "Polygon" and "SpatialPolygons")

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, reverse = TRUE, ...)

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

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

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

Arguments

object
an object of one of the supported spatial classes.
...
(unused) argument of the generic.
reverse
logical (TRUE) indicating if the vertex order of the sp classes should be reversed to get the xylist/owin convention.

Value

  • Applying xylist to a polygon object, one gets a simple list, where each component (polygon) is a list of "x" and "y" coordinates. These represent vertex coordinates following spatstat's "owin" convention (anticlockwise order without repeating any vertex). The opposite vertex order can be retained for the sp-classes by the non-default use with reverse=FALSE.

code

xylist

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".

Details

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