I have some simple polygons that I would like to convert to polylines using the sf
package in R. I have found st_polygonize
to convert polylines to polygons but I cannot but the reserve operation. Some documentation suggested that st_segmentize
would work but I haven't found it useful.
-
Hang on, do you want polygon to polyline or polyline to polygon? Your title says one, your first line says the other, then you say polylines to polygons... – Spacedman Sep 4 '19 at 19:37
-
I made a mistake in the title. Thanks for your answer to my question in the text! It's much simpler than I thought. – user3386170 Sep 4 '19 at 19:44
Add a comment
|
To convert a simple polygon P
(that defines an area) to a line L
use:
L = st_cast(P,"LINESTRING")
eg using pl
from example(st_polygon)
:
> st_polygon(pl)
POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))
> st_cast(st_polygon(pl),"LINESTRING")
LINESTRING (0 0, 1 0, 1 1, 0 1, 0 0)