geost.accessor.GeostFrame.find_point_pairs#

GeostFrame.find_point_pairs(points: str | Path | GeoDataFrame | GeometryType, max_distance: float | int, n_points: int = None, return_distance: bool = False, return_dataframe: bool = False) → ndarray | DataFrame[source]#

Find pairs of points between the data and the given query points that are within a specified maximum distance.

Parameters:
  • points (str | Path | gpd.GeoDataFrame | GeometryType) – Any type of point geometries that can be used for the selection: GeoDataFrame containing points or filepath to a shapefile like file, or Shapely Point, MultiPoint or list containing Point objects.

  • max_distance (float | int) – Maximum distance between points to be considered a pair.

  • n_points (int, optional) – The maximum number of nearest points to return for each point. If None, all points within the max_distance are returned. The default is None.

  • return_distance (bool, optional) – If True, the distances between the paired points will be returned as well. The default is False.

  • return_dataframe (bool, optional) – If True, the result will be returned as a pandas DataFrame with columns [“left_nr”, “right_nr”, “distance”]. Note that this ignores the return_distance parameter, as the distance column will always be included in the DataFrame. The default is False, which returns a numpy array.

Returns:

Array of shape (n_pairs, 2) containing the dataframe indices of the paired points in the data (column 0) and the query points (column 1) within range. If return_distance is True, the array will have shape (n_pairs, 3) with the third column containing the distances between the paired points.

If return_dataframe is True, a pandas DataFrame will be returned instead with columns [“left_nr”, “right_nr”, “distance”].

Return type:

np.ndarray | pd.DataFrame