merge_intersecting_polygons | R Documentation |
This function merges intersecting polygons by inserting the sub-polygon into the main polygon where they intersect.
merge_intersecting_polygons(
main_poly,
sub_poly,
cvars = c("x_orig", "y_orig"),
col_rm = TRUE
)
main_poly |
The main polygon(s) as a data frame. |
sub_poly |
The sub-polygon(s) as a data frame. |
cvars |
A character vector specifying the column names of the x and y coordinates in the main and sub-polygons. |
col_rm |
Logical indicating whether to remove additional columns added during processing. |
The function iterates through each vertex of the sub-polygon and checks if it
lies within the main polygon using sp::point.in.polygon
.It then identifies
the segments of the main polygon where the sub-polygon intersects and inserts
the sub-polygon accordingly. Finally, it adjusts the direction of the
sub-polygon if necessary and removes any extra columns if specified.
A data frame representing the merged polygons.
main_poly <- data.frame(x = c(0, 1, 1, 0), y = c(0, 0, 1, 1))
sub_poly <- data.frame(x = c(0.5, 1.5, 1.5, 0.5), y = c(0.5, 0.5, 1.5, 1.5))
merge_intersecting_polygon(main_poly, sub_poly)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.