merge_intersecting_polygons.Rd
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
)
A data frame representing the merged polygons.
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.
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)