I have linestring features, which look like bent linestrings, hemicycles or convex or concave linestrings. In the moment I can select the distance between the startpoint and endpoint of each feature. Now I want to calculate the vertical (orthogonal) distance between
a) the imaginary line between startpoint and endpoint
b) and the most distant point of the linestring
Like the maximum orthogonal distance between the deepest point in a hole referring to a straight surface.
How can I calculate this with postgis?
Here is a picture:
Best Answer
Consider some test data similar top the thick line in the question's figure:
the straight line (dashed) can be constructed from the start and end points:
Distances from each vertex (coordinate) can then be found to the straight line:
All of this logic can be put into a nested query to get the maximum depth from the geometry:
which is 120.67515848571 for this example.