I know how to go from
line = LineString([(0, 0), (1, 1), (2, 2)])
to
LINESTRING ((0 0), (1 1), (2 2))
But not the other way around. How do I do this?
The reason I need to do this is that I want to be able to apply the following function to split my LINESTRING into its sides.
from shapely.geometry import LineString, LinearRing
def segments(curve):
return list(map(LineString, zip(curve.coords[:-1], curve.coords[1:])))
line = LineString([(0, 0), (1, 1), (2, 2)])
line_segments = segments(line)
for segment in line_segments:
print(segment)
and it cannot be applied to WKT representations of linestrings.
from shapely.wkt import loads line2 = loads(wkt) print(line2)– Taras Dec 18 '21 at 16:50