Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

coerce-gpc-methods

Conversion between polygonal "owin" and "gpc.poly"


Description

Package polyCub implements converters between the classes "owin" of package spatstat.geom and "gpc.poly" of package rgeos (originally from gpclib).

Usage

owin2gpc(object)

gpc2owin(object, ...)

as.owin.gpc.poly(W, ...)

Arguments

object

an object of class "gpc.poly" or "owin", respectively.

...

further arguments passed to owin.

W

an object of class "gpc.poly".

Value

The converted polygon of class "gpc.poly" or "owin", respectively. If neither package rgeos nor gpclib are available, owin2gpc will just return the pts slot of the "gpc.poly" (no formal class) with a warning.

Note

The converter owin2gpc requires the package rgeos (or gpclib) for the formal class definition of a "gpc.poly". It will produce vertices ordered according to the sp convention, i.e. clockwise for normal boundaries and anticlockwise for holes, where, however, the first vertex is not repeated!

Author(s)

Sebastian Meyer

See Also

xylist, and the package rgeos for conversions of "gpc.poly" objects from and to sp's "SpatialPolygons" class.

Examples

if (require("rgeos") && require("spatstat.geom")) {
    ## use example polygons from
    example(plotpolyf, ask = FALSE)

    letterR  # a simple "xylist"
    letterR.owin <- owin(poly = letterR)
    letterR.gpc_from_owin <- owin2gpc(letterR.owin)
    letterR.xylist_from_gpc <- xylist(letterR.gpc_from_owin)
    stopifnot(all.equal(letterR, lapply(letterR.xylist_from_gpc, "[", 1:2)))
    letterR.owin_from_gpc <- as.owin(letterR.gpc_from_owin)
    stopifnot(all.equal(letterR.owin, letterR.owin_from_gpc))
}

polyCub

Cubature over Polygonal Domains

v0.8.0
GPL-2
Authors
Sebastian Meyer [aut, cre, trl] (<https://orcid.org/0000-0002-1791-9449>), Leonhard Held [ths], Michael Hoehle [ths]
Initial release
2021-01-26

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.