This article presents a method for the calculating similarity of two trajectories. The method is especially designed for a situation where the points of the trajectories are distributed sparsely and at non-equidistant intervals. The proposed method is based on giving different weights to different points: points that are close to each other get smaller weights than the points that do not have neighbors nearby. The effectiveness of the method was tested with 12 data sets generated from two benchmark data sets. The classifying accuracy of the proposed similarity measure was compared with three other methods, such as dynamic time warping, and it was noted that the new proposed method classifies instances mainly more accurately and faster than the other three methods.