Description Usage Arguments Details Value Author(s) References See Also Examples
This function attempts to remove selfintersections and duplicated vertices from the given polygon.
1 2  polysimplify(A, ..., eps, x0, y0,
filltype = c("evenodd", "nonzero", "positive", "negative"))

A 
Data specifying a polygon or polygons. See Details. 
... 
Ignored. 
eps 
Spatial resolution for coordinates. 
x0,y0 
Spatial origin for coordinates. 
filltype 
Polygonfilling rule. See Details. 
This is an interface to the function SimplifyPolygons
in
Angus Johnson's C++
library Clipper.
It tries to remove selfintersections from the supplied polygon,
by performing a boolean union operation using the nominated
filltype
. The result may be one or several polygons.
The argument A
should be either
a list containing two components x
and y
giving the coordinates of the vertices of a single polygon.
The last vertex should
not repeat the first vertex.
a list
of list(x,y)
structures giving
the coordinates of the vertices of several polygons.
The argument filltype
determines the polygon fill type.
The default rule is evenodd filling, in which every polygon edge demarcates a boundary between the inside and outside of the region. It does not matter whether a polygon is traversed in clockwise or anticlockwise order. Holes are determined simply by their locations relative to other polygons such that outers contain holes and holes contain outers.
Under the nonzero filling rule, an outer boundary must be traversed in clockwise order, while a hole must be traversed in anticlockwise order.
Under the positive
filling rule, the filled region
consists of all points with positive winding number.
Under the negative
filling rule, the filled region
consists of all points with negative winding number.
Calculations are performed in integer arithmetic
after subtracting x0,y0
from the coordinates,
dividing by eps
, and rounding to the nearest integer.
Thus, eps
is the effective spatial resolution.
The default values ensure reasonable accuracy.
Data specifying polygons, in the same format as A
.
Angus Johnson. Ported to R by Adrian Baddeley Adrian.Baddeley@curtin.edu.au.
Clipper Website: http://www.angusj.com
polyclip
,
polyoffset
,
polylineoffset
,
polyminkowski
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15  theta < 2 * pi * (0:5) * 2/5
A < list(list(x=sin(theta), y=cos(theta)))
B < polysimplify(A, filltype="nonzero")
opa < par(mfrow=c(1,2))
plot(c(1,1),c(1,1), type="n", axes=FALSE, xlab="", ylab="")
with(A[[1]], segments(x[6], y[6], x[1], y[1], col="red"))
points(A[[1]], col="red")
with(A[[1]], text(x[1:5], y[1:5], labels=1:5, cex=2))
plot(c(1,1),c(1,1), type="n", axes=FALSE, xlab="", ylab="")
polygon(B[[1]], lwd=3, col="green")
with(B[[1]], text(x,y,labels=seq_along(x), cex=2))
par(opa)

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.
Please suggest features or report bugs in the GitHub issue tracker.
All documentation is copyright its authors; we didn't write any of that.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.