points_to_polygon | R Documentation |
Given a table of x and y coordinates data generate a sfc_POLYGON
points_to_polygon(
x = dplyr::tibble(x = c(1, 2, 1, 0), y = c(0, 1, 2, 1)),
crs = "WGS84"
)
x |
table or matrix of x and y column of coordinates |
crs |
character or numeric coordinate ref system flag |
sfc_POLYGON object
## Not run:
# An example of interating over a number of sets of points in a grouped table
x <- dplyr::tibble(
name = c('a', 'a', 'a', 'a', "b", "b", "b", "b"),
x = c(1,2,1,0, 3,4,4,5),
y = c(0,1,2,1, 8,8,9,9))
make_one_polygon <- function(x, y, ...){
cat(str(x, "\n"))
points_to_polygon(x, ...)
}
p <- x |>
dplyr::group_by(name) |>
dplyr::group_map(make_one_polygon, crs = "WGS84") |>
dplyr::bind_rows()
## End(Not run)m
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.