Lets say I have an arbitrary shapely.geometry Linestring like the following as an example, how do I get the turning points (5 in this example)?
For clearity I mean the curvature not the peaks/valleys.
Sample code:
from shapely.geometry import LineString
import matplotlib.pyplot as plt
import numpy as np
# let's use a sine curve as our example line
x = np.arange(0, 6 * np.pi, 0.5)
y = np.sin(x)
xy = list(zip(x, y))
line = LineString(xy)
plt.plot(*line.xy)
plt.show()
I tried to iterate all points of the Linestring and detect if y is increasing or decreasing, but this approach will fail if the Linestring is rotated by 90° for example.
