Converts a list of points specifying polygons into a spatial object
pointList2poly(points_list, df = NULL, ...)
a simple feature collection with POLYGON geometry.
list of data frames of xy coordinates. In each data.frame the last row must be the same as the first row
data.frame. Optional data.frame to be associated to polygons
arguments to be passed to st_sfc
ellipses4Crown
# Compute coordinates of polygons
ellipses <- ellipses4Crown(c(0, 10), c(0, 10), c(2, 2), c(3, 4), c(2.5, 3), c(2, 3),
id = c("A", "B")
)
# Convert to sf object
ellipses1 <- pointList2poly(ellipses)
ellipses1
# Convert to sf object with user-defined data.frame
ellipses2 <- pointList2poly(ellipses, df = data.frame(info = 1:2))
# draw ellipses
plot(ellipses2, col = ellipses2$info)
Run the code above in your browser using DataLab