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

sfg2gpc

Convert polygonal "sfg" to "gpc.poly"


Description

Package polyCub implements a converter from class "(MULTI)POLYGON" of package sf to "gpc.poly" of package rgeos (originally from gpclib) such that polyCub.exact.Gauss can be used with simple feature polygons.

Usage

sfg2gpc(object)

Arguments

object

a "POLYGON" or "MULTIPOLYGON" "sfg" object.

Value

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

Note

Package rgeos (or gpclib) is required for the formal class definition of a "gpc.poly".

Author(s)

Sebastian Meyer

See Also

Examples

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

    letterR  # a simple "xylist"
    letterR.sfg <- st_polygon(lapply(letterR, function(xy)
        rbind(cbind(xy$x, xy$y), c(xy$x[1], xy$y[1]))))
    print(letterR.sfg)
    stopifnot(identical(letterR, xylist(letterR.sfg)))
    
    ## convert sf "POLYGON" to a "gpc.poly"
    letterR.gpc_from_sfg <- sfg2gpc(letterR.sfg)
    print(letterR.gpc_from_sfg)
    letterR.xylist_from_gpc <- xylist(letterR.gpc_from_sfg) # with hole info
    stopifnot(identical(letterR, lapply(letterR.xylist_from_gpc, "[", 1:2)))
}

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.