However, the problem is that my polylines are approximately congruent (an example of the small difference of polylines is marked in black):
The objective is to measure the similarity between two polylines, assuming that small deviations (around 5%) are allowed and must be ignored. So, the similarity between above provided polylines must be close to 100%.
The question is how to measure similarity between such polylines using R? My approach is explained here, however it is very computationally expensive, and the solution of whuber assumes that polylines are congruent, not approximately congruent.