Registry / data / kdtree

kdtree

JSON →
library0.16pypypi✓ verified 80d ago

A Python implementation of a kd-tree for efficient spatial searching. Current version 0.16. Intermittent releases, last updated 2017.

pip install kdtree
INSTALL
IMPORT
SIG · KDTREE
K
kdtree
datapythonv0.16
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

KDNode
from kdtree import KDNode
from kdtree import KDTree
create
from kdtree import create
visualize
from kdtree import visualize

Create a kd-tree from points and perform a nearest neighbor search.

from kdtree import KDTree # Create a KDTree from a list of points (each point is a tuple) points = [(2, 3), (5, 4), (9, 6), (4, 7), (8, 1), (7, 2)] tree = KDTree(points) # Search for the nearest neighbor to a query point query = (9, 2) nearest = tree.search_nearest(query) print(f'Nearest neighbor to {query}: {nearest}')
Debug
Known issues
breakingThe 'search_nn' method returns a single result in older versions; newer versions return a list.
fix
Upgrade to >=0.12 and use 'search_nearest' for consistent single-result behavior.
affects: <0.12
deprecatedThe 'add' method does not exist in v0.16; use the constructor to build the tree.
fix
Pass all points at construction time: KDTree(points).
affects: 0.16
gotchaPoints must be tuples/lists of numbers; mixing types (e.g., int and float) is fine, but non-numeric types cause errors.
fix
Ensure all point coordinates are numeric (int or float).
affects: all
Upgrade
Version history
0.16latest on PyPI · released Oct 19, 2017
Audit
Dependencies

No dependency data recorded yet.

Agent activity
13 hits · last 30 days
node
10
Resources
kdtree — pip install kdtree · libregistry