poly1 <- "POLYGON ((0 0, 0 10, 10 10, 10 0, 0 0))"
poly2 <- "POLYGON ((5 5, 5 15, 15 15, 15 5, 5 5))"
geos_intersection(poly1, poly2)
geos_difference(poly1, poly2)
geos_sym_difference(poly1, poly2)
geos_union(poly1, poly2)
line <- "LINESTRING (11 0, 11 10)"
geos_snap(poly1, line, tolerance = 2)
geos_shared_paths("LINESTRING (0 0, 1 1, 2 2)", "LINESTRING (3 3, 2 2, 1 1)")
## generate a line that connects two geometries at their nearest place
## (not necessarily a vertex of either)
a <- as_geos_geometry("LINESTRING (0.5 2, 0.5 3)")
b <- as_geos_geometry("POLYGON ((0 1, 0.5 0, 1 1, 0 1))")
plot(c(a, b), col = c("grey", "firebrick"), lwd = 10)
plot(geos_clearance_line_between(a, b), add = TRUE)
Run the code above in your browser using DataLab