tracktable.domain.rtree module¶
Module contents¶
tracktable.domain.rtree - Find points in boxes and nearest neighbors with an R-tree.
- class tracktable.domain.rtree.RTree(points=None)[source]¶
Bases:
object
- find_nearest_neighbors(seed_point, num_neighbors)[source]¶
Find points near a search point
Finds the K nearest neighbors to a search point.
Note
That if the search point is already present in the R-tree then it will be one of the results returned.
- Parameters
seed_point (Tracktable point) – Point whose neighbors you want to find
num_neighbors (int) – How many neighbors to find
Returns: Sequence of points originally supplied
- find_points_in_box(min_corner, max_corner)[source]¶
Find points inside a box
Finds all of the points in a box between minimum and maximum corner points.
- Parameters
min_corner (Tracktable point) – Minimum corner to bound the box
max_corner (Tracktable point) – Maximum corner to bound the box
Returns: Sequence of points originally supplied
- insert_point(point)[source]¶
Add a single point to the R-tree.
- Parameters
point (array-like or FeatureVector) – Point to add. If this is not the first point added, it must have the same dimension as all previous points.
- Returns
No return value.
- Raises
ValueError – The point you have supplied has a different number of components than the points already in the tree.
- insert_points(points)[source]¶
Add many points to the R-tree
- Parameters
points (sequence of points) – Points to insert into the R-tree.
- intersects(min_corner, max_corner)[source]¶
Find points/objects that intersect a box
Finds all of the points/objects that intersect a box between minimum and maximum corner points.
- Parameters
min_corner (Tracktable point) – Minimum corner to bound the box
max_corner (Tracktable point) – Maximum corner to bound the box
Returns: Sequence of points originally supplied
- property points¶
Return the points currently held in the r-tree
Note
This will return the points as originally supplied by the user, not the feature vectors that actually populate the tree.
Returns: Sequence of points originally supplied