Description Usage Arguments Value Author(s) Examples
View source: R/compute-polygon-centroid.R
This function takes in a data frame containing one or more polygons, and computes the centroid (geometric center) of each polygon.
1 | compute_polygon_centroid(vertex.df)
|
vertex.df |
A data frame where each row corresponds to the vertex of a polygon.
It must contain the columns |
A data frame that contains three columns:
group |
The group number of the polygon |
x, y |
The coordinates of the centroid |
Mathias Isaksen mathiasleanderi@gmail.com
1 2 3 4 5 6 7 8 9 10 | # Example with multiple polygons
vertex.df = compute_regular_polygons(
center = data.frame(x = c(0, 10), y = c(0, 0)),
radius = 1,
num.edges = c(4, 1000)
)
centroid.df = compute_polygon_centroid(vertex.df)
# Centroids should be (0, 0) and c(10, 0)
print(centroid.df)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.