[SciPy-User] 2D NN search in a 3D point cloud

Andrej Kobler andrej.kobler@gozdis...
Fri Sep 23 00:40:10 CDT 2011


I need the 3rd coordinate value after selecting the NN in 2D. You suggestion
could be OK, if you know of a way to conserve the links between 2D points
and their coordinate values in the 3rd dimension.


-----Original Message-----
From: scipy-user-bounces@scipy.org [mailto:scipy-user-bounces@scipy.org] On
Behalf Of Bastian Weber
Sent: 22. september 2011 18:11
To: SciPy Users List
Subject: Re: [SciPy-User] 2D NN search in a 3D point cloud

On 09/22/2011 02:13 PM, Andrej Kobler wrote:
> Hi,
> in a cloud of XYZ points I'd like to search for nearest neighbors in XY
> plane using scipy.spatial.KDTree/cKDTree. The problem is that
> KDTree.query takes into account all the given dimensions, not just the
> desired subset of dimensions. Is there a simple way to have data with 3
> or more dimensions and use only 2 for NN search?

Probably I dont have enough insight but I simply would try to neglect 
the last coordinate of the data.

Assuming you have points_xyz.shape == (N,3) where N is the number of 
points then you could simply do:

points_xy = points_xyz[:,:2].

Applying the NN search on this data should give you the desired result.

Best regards,

SciPy-User mailing list

More information about the SciPy-User mailing list