I'm working on deriving the centerline of a polygon, similar to this question or this one, using a different approach. I'm 90% done with the task, but cannot reach the final step. My approach is to calculate a LeastCostPath through the channel center.
In order to do this, I first calculated a surface within the polygon with the distance to the polygon edge (see image 2). In order to get values from 0 - 1 with low values being in the polygon center, I used the following operation:
rastervalueNormalizedInverted = 1-(eucideanDistance/maxRasterValue)
Now I can just calculate the least cost path between the start and end of my polygon and I get a beautiful line without dangles and without the issue of having to specify threshold values (see image 3).
I have the feeling that I'm 90% done at this point. All I have to do now is consider the side channel in polygon, which were not considered by the initial LeastCostPath calculation.
I am completely stuck at this point! I've tried various approaches to get the diverging and converging line for the two side arms seen in the image, with no success. Can anybody provide a clue in which direction I could start looking?
Here are the images to illustrate:
The original Polygon:
Normalized, inverted euclidean distance to the polygon edge:
Least Cost Path from the start to endpoint of the channel returns a nice line:
