polygon_areas: Polygon area for simple or list of polygons

polygon_areasR Documentation

Polygon area for simple or list of polygons

Description

Polygon area for simple or list of polygons

Usage

polygon_areas(x, y = NULL, simplify = FALSE, verbose = FALSE, ...)

Arguments

x

numeric input in one of the following formats:

  • numeric vector of coordinates for single polygon input, which also requires y is supplied as numeric vector with equal length.

  • list of numeric vectors representing multiple polygons, which also requires y is supplied as equivalent list.

  • list of polygons, each polygon contains elements "x" and "y".

  • list of polygons, each polygon contains a list of polygon component parts which each contain elements "x" and "y".

y

numeric vector or list of numeric vectors, compatible with x, or NULL when x contains both coordinates.

simplify

logical indicating whether area should be summed for each polygon, potentially containing nested component polygons.

  • simplify=TRUE returns numeric vector with one total area per polygon.

  • simplify=FALSE returns a list of numeric areas, using nested list to indicate component polygons.

  • Note that this step does not manipulate the polygons in any way, for example it does not call union over component polygons, therefore the component polygons may overlap.

verbose

logical indicating whether to print verbose output.

...

additional arguments are ignored.

Value

numeric vector with polygon area for each individual polygon in the input x,y.

  • When x is a list that contains "x" and "y" elements, those elements are used.

  • When x and y both contain a list of numeric vectors, each vector is considered coordinates of a polygon, and the area is returned for each polygon.

  • When x and y are numeric vectors, it is considered a single polygon, and thus one area is returned.

See Also

Other venndir polygons: bbox_polygon_list(), eulerr_to_polygon_list(), get_largest_polygon_list(), get_venn_polygon_shapes(), intersect_polygon_list(), labelr_polygon_list(), minus_polygon_list(), nudge_polygon_coords(), nudge_polygon_list(), plot_polygon_list(), polygon_circles(), polygon_ellipses(), polygon_list_labelr(), polygon_list_to_xy_list(), rescale_polygon_list(), simple_ellipse(), union_polygon_list(), xy_list_to_polygon_list()

Examples

D <- list(
   x=c(-3, 3, 3, 0, -3),
   y=c(-3, -3, 1.5, 4, 1.5))
polygon_areas(D)

E <- list(
   x=c(-3, 3, 3, -3),
   y=c(-3, -3, 3, 3))
polygon_areas(E)

DElist <- list(
   x=list(
      D=c(-3, 3, 3, 0, -3),
      E=c(-3, 3, 3, -3)),
   y=list(
      D=c(-3, -3, 1.5, 4, 1.5),
      E=c(-3, -3, 3, 3)))
polygon_areas(DElist)

# list of polygons
poly_list <- list(D=D, E=E)
polygon_areas(poly_list)

# list of nested polygons
polygon_areas(list(DE=poly_list, D=D, E=E))

polygon_areas(list(DE=poly_list, D=D, E=E), simplify=TRUE)


jmw86069/venndir documentation built on June 15, 2024, 1:52 p.m.