[Numpy-discussion] finding close together points.

Peter Schmidtke pschmidtke at mmb.pcb.ub.es
Wed Nov 11 02:30:57 EST 2009


On Tue, 10 Nov 2009 16:07:32 -0800, Christopher Barker
<Chris.Barker at noaa.gov> wrote:
> Hi all,
> 
> I have a bunch of points in 2-d space, and I need to find out which 
> pairs of points are within a certain distance of one-another (regular 
> old Euclidean norm).

How big is your set of points?

> 
> scipy.spatial.KDTree.query_ball_tree() seems like it's built for this.
> 
> However, I'm a bit confused. The first argument is a kdtree, but I'm 
> calling it as a method of a kdtree -- I want to know which points in the 
> tree I already have are closer that some r from each-other.
> 
> If I call it as:
> 
> tree.query_ball_tree(tree, r)
> 
> I get a big list, that has all the points in it (some of them paired up 
> with close neighbors.) It appears I'm getting the distances between all 
> the points in the tree and itself, as though they were different trees.
> 
> This is slow, takes a bunch of memory, and I then have to parse out the 
> list to find the ones that are paired up.
> 
> Is there a way to get just the close ones from the single tree?
> 
> thanks,
> 
> -Chris

-- 

Peter Schmidtke

----------------------
PhD Student at the Molecular Modeling and Bioinformatics Group
Dep. Physical Chemistry
Faculty of Pharmacy
University of Barcelona




More information about the NumPy-Discussion mailing list