[Numpy-discussion] "Match" two arrays

Charles R Harris charlesr.harris@gmail....
Thu Apr 1 00:06:04 CDT 2010

On Wed, Mar 31, 2010 at 9:24 PM, Shailendra <shailendra.vikas@gmail.com>wrote:

> Hi All,
> I want to make a function which should be like this
> <code>
> cordinates1=(x1,y1) # x1 and y1 are x-cord and y-cord of a large
> number of points
> cordinates2=(x2,y2) # similar to condinates1
> indices1,indices2= match_cordinates(cordinates1,cordinates2)
> <code>
> (x1[indices1],y1[indices1]) "matches" (x2[indices2],y2[indices2])
> where definition of "match" is such that :
> If A is closest point to B and distance between A and B is less that
> delta than it is a "match".
> If A is closest point to B and distance between A and B is more that
> delta than there is no match.
> Every point has either 1 "match"(closest point) or none
> Also, the size of the cordinates1 and cordinates2 are quite large and
> "outer" should not be used. I can think of only C style code to
> achieve this. Can any one suggest pythonic way of doing this?
Take a look at KdTree in scipy spatial for finding nearest neighbors.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20100331/6cd8f95c/attachment.html 

More information about the NumPy-Discussion mailing list