polyclip
comments:
polyclip
defines two formats for "a polygon":
list
with x
,y
elements. Simple polygon.list
with list
of simple polygons above. Used for multi-polygons,
and/or holes within polygons.Polygons are not, and should not be closed. (Start and end points differ.)
Output is therefore inconsistent:
list
with x
,y
, for simple polygonlist
with list
of x
,y
for multi-polygonSometimes Venn overlap polygons will be multi-part, most common for 4-way Venn using ellipses, sometimes both ends of the A ellipse represent unique elements in A, not in any other set.
Sometimes Venn overlap polygons will contain a hole, e.g. A is completely inside B.
When rescaling, rotating a polygon:
simple polygons are rotated about their center (or fixed point)
complet polygons are rotated about their collective center (or fixed point)
When drawing:
polypath()
recognizes x
and y
as long vectors.
NA
between polygons,
which recognizes holes, and multi-part polygons.ggplot2::geom_polygon()
uses x
, y
, id
, subid
id
is used to distinguish each distinct polygon.subid
is used to distinguish holes, multi-part polygonsgrid::grid.path()
recognizes x
, y
, pathId
, id
pathId
defines each polygonid
defines each sub-polygon, for example polygon holes or multi-part polygonsvenndir()
with polyclip equivalent function callsvenn_spdf
to data.frame
list
with x,y coordinates: single, simple polygonpolygon (matrix): matrix with x,y columns: single, simple polygon
polygon_list: list
of named polygons
each named polygon may contain multiple polygons (rule="evenodd" to allow holes)
internal multiple polygons do not have names
xy_list: list
of elements "x"
, "y"
, each is a list
"x"
contains list
of numeric
vectors for each polygon
"x"
can contain nested list for multi-layer polygons
vectors by id
x
and y
are continuous vectors, with id
to define each polygon
grid::grid.path(x, y, id)
used by ggplot2::geom_polygon(x, y, group=id)
vectors by NA ("coord_list"
)
x
and y
are continuous vectors, each polygon separated by NA
graphics::polypath(x, y, rule="evenodd")
- must be closed polygons (start-end use same coordinate)graphics::polygon()
but it does not recognize holesjampolygon
, jampolygons
(I don't want to do any of this work, new classes, methods, etc. There should already be an R package here, without needing to install huge map and GPS-aware geometry libraries.)
goal is to use one format to store polygons
convert for tools only when needed
lossless format, fully describes polygons, multi-polygons, holes
jampolygon
represents one "polygon" with one or more internal polygons,
necessary to associate a hole with its proper parent
list
of polygons, even when only onecolor
, label
, etcit will be stored in a data.frame
field
jampolygons
is a list
of jampolygon
objects
can it contain another polygons
? hopefully not, but maybe
it will be stored in a data.frame
column
could these be stored as data.frame
?
polygon_id="name"
, "name.1"
, "name.2"
- requires "name"
to be unique
jampolygon <- list(
# first polygon
name1=list(
# first polygon for name1
list(x, y),
# second polygon for name1
list(x, y)),
name2=list(
list(x, y),
list(x, y))
data.frame
format:column for coordinates
contains list
of polygons - with one or more polygons
ultimately list
with numeric
elements: "x"
, "y"
use other data.frame columns for attributes
venn_spdf
as drop-in replacementAdd the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.