sfg2gpc function

Convert polygonal "sfg" to "gpc.poly"

Convert polygonal "sfg" to "gpc.poly"

Package polyCub implements a converter from class "(MULTI)POLYGON" of package list("sf")

to "gpc.poly" of package list("gpclib")

such that polyCub.exact.Gauss

can be used with simple feature polygons.

sfg2gpc(object)

Arguments

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

Returns

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

Note

Package gpclib is required for the formal class definition of a "gpc.poly".

Examples

## use example polygons from example(plotpolyf, ask = FALSE) letterR # a simple "xylist" letterR.sfg <- sf::st_polygon(lapply(letterR, function(xy) rbind(cbind(xy$x, xy$y), c(xy$x[1], xy$y[1])))) letterR.sfg stopifnot(identical(letterR, xylist(letterR.sfg))) ## convert sf "POLYGON" to a "gpc.poly" letterR.gpc_from_sfg <- sfg2gpc(letterR.sfg) letterR.gpc_from_sfg

See Also

xylist

Author(s)

Sebastian Meyer

  • Maintainer: Sebastian Meyer
  • License: GPL-2
  • Last published: 2025-02-11