frechet_distance#

GeosSeriesAccessor.frechet_distance(other=None, manner=None, **kwargs)#

Compute the discrete Fréchet distance between two geometries.

Applies shapely.measurement.frechet_distance to (self, other) and returns the result. If no other data is given, the function gets applied to all possible combinations of the self data, by expanding the array.

Parameters:
  • other (pandas.Series or numpy.ndarray or shapely.Geometry, optional) – Second argument to frechet_distance; Default self.

  • manner ('keep' or 'align' or 'expand', optional) – How to apply the frechet_distance to the data; Default None .

  • kwargs – Keyword arguments passed to frechet_distance.

Returns:

Series with the result of the function applied to self and other, with the same index as self. numpy.ndarray: 2-Dimensional array with the results of the function applied to each combination of geometries between self and other.

Return type:

pandas.Series

Raises:

ValueErrorother argument is not a geos Series or shapely NumPy Array

Note

The manner argument dictates how the data gets transformed before applying frechet_distance:

  • keep:

    Keep the original data as is and simply run the function. This returns a Series where the index is the same as the self data.

  • align:

    Align both Series according to their index, before running the function (we align the data according the self data). This returns a Series where the index is the same as the self data.

  • expand:

    Expand the data with a new index, before running the function. This means that the result will be an array of dimensions <len(a), len(b)> containing the result of all possible combinations of geometries.

Of course, not every method is applicable for each type of other input. Here are the allowed manners for each type of input, as well as the default value:

  • Series: keep, align, expand (default: align)

  • 1D ndarray: keep, expand (default: keep)

  • nD ndarray: keep (default: keep)

  • Geometry: keep (default: keep)

  • None (aka. use self): expand (default: expand)