tobac.analysis.spatial.calculate_nearestneighbordistance#

tobac.analysis.spatial.calculate_nearestneighbordistance(features, method_distance=None)#

Calculate the distance between a feature and the nearest other feature in the same timeframe.

Parameters:
  • features (pandas.DataFrame) – DataFrame of the features whose nearest neighbor distance is to be calculated. Needs to contain either projection_x_coordinate and projection_y_coordinate or latitude and longitude coordinates.

  • method_distance ({None, 'xy', 'latlon'}, optional) – Method of distance calculation. ‘xy’ uses the length of the vector between the two features, ‘latlon’ uses the haversine distance. None checks wether the required coordinates are present and starts with ‘xy’. Default is None.

Returns:

features – DataFrame of the features with a new column ‘min_distance’, containing the calculated minimal distance to other features.

Return type:

pandas.DataFrame