I have the data of trucks (http://www.chorochronos.org/).
This data are gps coordinates of multiple trajectories of trucks in Athens.
I have to calculate the similarity between the trajetories, in order to delete those that are very similar!
Red And Green are similar, but blue, black and (red or green) are different trajectories.
I want to delete one of the similares, red or green.
Data are in points (geometry , lat and long , x and y)(coordinates gps), the image are examples of trajectories
Best Answer
A really easy, but not fantastic measure is to get the Hausdorff distance between each combination, which is done with the ST_HausdorffDistance function. Using approximate LineStrings from your figure, these are all shown in blue, and the Hausdorff distance is shown for one of the pairs of lines in red:
And the query to sort the 6 combinations in descending order:
So it works fine for this example, but it isn't a great or robust technique for clustering lines, since the only metric is the single point with the greatest distance, rather than comparing the differences of complete lines. There are much better methods, but they will be more complicated.