Polygon-Geometry | R Documentation |
Geometry functions for irregular polygons.
PolygonArea(x, y = NULL, positive = TRUE)
PolygonCentre(x, y = NULL)
PolygonCenter(x, y = NULL)
GrowPolygon(x, y = NULL, buffer = 0)
x , y |
Vectors containing the coordinates of the vertices of the polygon. |
positive |
If vertices are specified in an anticlockwise direction,
the polygon will be treated as a hole, with a negative area, unless
|
buffer |
Numeric specifying distance by which to grow polygon. |
PolygonArea()
returns the area of the specified polygon.
PolygonCentre()
returns a single-row matrix containing the
x and y coordinates of the geometric centre of the polygon.
GrowPolygon()
returns coordinates of the vertices of polygon
after moving each vertex buffer
away from the polygon's centre.
PolygonArea()
: Calculate the area of an irregular polygon
PolygonCentre()
: Locate the centre of a polygon
GrowPolygon()
: Enlarge a polygon in all directions
Martin R. Smith (martin.smith@durham.ac.uk)
Other tiling functions:
TriangleCentres()
,
TriangleInHull()
x <- c(-3, -1, 6, 3, -4)
y <- c(-2, 4, 1, 10, 9)
plot(x, y, frame.plot = FALSE)
polygon(x, y)
PolygonArea(x, y)
points(PolygonCentre(x, y), pch = 3, cex = 2)
polygon(GrowPolygon(x, y, 1), border = "darkgreen",
xpd = NA # Allow drawing beyond plot border
)
# Negative values shrink the polygon
polygon(GrowPolygon(x, y, -1), border = "red")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.