View source: R/cnt_path_guess.R
cnt_path_guess | R Documentation |
This function, as follows from the title, tries to guess the polygon centerline by connecting the most distant points from each other. First, it finds the point most distant from the polygon's centroid, then it searches for a second point, which is most distant from the first. The line connecting these two points will be the desired centerline.
cnt_path_guess(input, skeleton = NULL, return_geos = FALSE, ...)
input |
|
skeleton |
|
return_geos |
|
... |
Arguments passed on to
|
An sf
, sfc
or SpatVector
class
object of a LINESTRING
geometry
library(sf)
library(geos)
lake <-
sf::st_read(
system.file("extdata/example.gpkg", package = "centerline"),
layer = "lake",
quiet = TRUE
) |>
geos::as_geos_geometry()
# Find lake's centerline
lake_centerline <- cnt_path_guess(input = lake, keep = 1)
# Plot
plot(lake)
plot(lake_centerline, col = "firebrick", lwd = 2, add = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.