movingpandas.Trajectory.frechet_distance#
- Trajectory.frechet_distance(other, units=(None, None, None, None))#
Return the Fréchet distance to the other geometric object (based on shapely https://shapely.readthedocs.io/en/stable/reference/shapely.frechet_distance.html). The Fréchet distance is a measure of the similarity between curves that takes into account the location and ordering of the points along the curves. Shapely computes the discrete Fréchet distance, which only considers the recorded points and not the line interpolated between them. The result therefore depends on how densely each trajectory is sampled, and a coarsely sampled trajectory can score much higher than the shape of the curves alone would suggest.
The distance is computed using Euclidean geometry, so a
UserWarningis raised for trajectories in a geographic (lat/lon) CRS. Project to a suitable planar CRS first for meaningful results.If units have been declared:
For geographic projections, in declared units
For known CRS units, in declared units
For unknown CRS units, in declared units as if CRS is in meters
- Parameters:
other (shapely.geometry or Trajectory) – Other geometric object or trajectory
units (str) – Units in which to calculate distance values (default: CRS units) For more info, check the list of supported units at https://movingpandas.org/units
- Returns:
Fréchet distance
- Return type:
float