geokdtree.kdtree API documentation

# geokdtree.kdtree

View Source

     1from .core import kdtree, closest_point
     2
     3
     4class KDTree:
     5    def __init__(self, points):
     6        """
     7        Function:
     8
     9        - Build a KDTree from a list of n dimensional cartesian points.
    10
    11        Required Arguments:
    12
    13        - `points`
    14            - Type: list of tuples
    15            - What: A list of n dimensional cartesian points to build the KDTree from
    16
    17        Returns:
    18
    19        - A KDTree object that can be used to find the closest point to a given point.
    20        """
    21        self.tree = kdtree(points, depth=0, axis_count=len(points[0]))
    22
    23    def closest_point(self, point):
    24        """
    25        Function:
    26
    27        - Find the closest point in the KDTree to a given point.
    28
    29        Required Arguments:
    30
    31        - `point`
    32            - Type: tuple
    33            - What: The point to find the closest point to
    34
    35        Returns:
    36
    37        - The closest point found in the KDTree to the given point.
    38        """
    39        return closest_point(self.tree, point)[0]

class KDTree: View Source

     5class KDTree:
     6    def __init__(self, points):
     7        """
     8        Function:
     9
    10        - Build a KDTree from a list of n dimensional cartesian points.
    11
    12        Required Arguments:
    13
    14        - `points`
    15            - Type: list of tuples
    16            - What: A list of n dimensional cartesian points to build the KDTree from
    17
    18        Returns:
    19
    20        - A KDTree object that can be used to find the closest point to a given point.
    21        """
    22        self.tree = kdtree(points, depth=0, axis_count=len(points[0]))
    23
    24    def closest_point(self, point):
    25        """
    26        Function:
    27
    28        - Find the closest point in the KDTree to a given point.
    29
    30        Required Arguments:
    31
    32        - `point`
    33            - Type: tuple
    34            - What: The point to find the closest point to
    35
    36        Returns:
    37
    38        - The closest point found in the KDTree to the given point.
    39        """
    40        return closest_point(self.tree, point)[0]

KDTree(points) View Source

     6    def __init__(self, points):
     7        """
     8        Function:
     9
    10        - Build a KDTree from a list of n dimensional cartesian points.
    11
    12        Required Arguments:
    13
    14        - `points`
    15            - Type: list of tuples
    16            - What: A list of n dimensional cartesian points to build the KDTree from
    17
    18        Returns:
    19
    20        - A KDTree object that can be used to find the closest point to a given point.
    21        """
    22        self.tree = kdtree(points, depth=0, axis_count=len(points[0]))

Function:

- Build a KDTree from a list of n dimensional cartesian points.

Required Arguments:

- `points`
  - Type: list of tuples
  - What: A list of n dimensional cartesian points to build the KDTree from

Returns:

- A KDTree object that can be used to find the closest point to a given point.

tree
def closest_point(self, point): View Source

    24    def closest_point(self, point):
    25        """
    26        Function:
    27
    28        - Find the closest point in the KDTree to a given point.
    29
    30        Required Arguments:
    31
    32        - `point`
    33            - Type: tuple
    34            - What: The point to find the closest point to
    35
    36        Returns:
    37
    38        - The closest point found in the KDTree to the given point.
    39        """
    40        return closest_point(self.tree, point)[0]

Function:

- Find the closest point in the KDTree to a given point.

Required Arguments:

- `point`
  - Type: tuple
  - What: The point to find the closest point to

Returns:

- The closest point found in the KDTree to the given point.