polygon_inside_polygon | R Documentation |
This set of functions checks whether one polygon is completely inside another, or whether two polygons intersect.
polygon_inside_polygon(a, b, strictly = TRUE)
polygon_intersects_polygon(a, b, strictly = TRUE)
a |
A data frame or matrix with two columns named |
b |
A data frame or matrix with two columns named |
strictly |
Logical, if |
These functions help in determining spatial relationships between two polygons. They work with data frames or matrices where the columns represent the x
and y
coordinates of the polygon's vertices.
polygon_inside_polygon()
: Checks whether all points of polygon a
lie inside polygon b
.
polygon_intersects_polygon()
: Checks whether the polygons a
and b
intersect, considering their vertices.
If strictly = TRUE
, the checks exclude points that lie on the edges of the polygons. If strictly = FALSE
, points on the edges are considered inside or intersecting.
polygon_inside_polygon()
: A logical value TRUE
if all points of polygon a
are inside polygon b
, FALSE
otherwise.
polygon_intersects_polygon()
: A logical value TRUE
if the polygons intersect, FALSE
otherwise.
polygon_a <- data.frame(x = c(1, 2, 2, 1), y = c(1, 1, 2, 2))
polygon_b <- data.frame(x = c(0, 3, 3, 0), y = c(0, 0, 3, 3))
# Check if polygon_a is completely inside polygon_b
polygon_inside_polygon(polygon_a, polygon_b) # TRUE
# Check if polygon_a intersects with polygon_b
polygon_intersects_polygon(polygon_a, polygon_b) # TRUE
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.