# [Numpy-discussion] &quot;Match&quot; two arrays

Neil Crighton neilcrighton@gmail....
Thu Apr 1 04:45:48 CDT 2010

```Shailendra <shailendra.vikas <at> gmail.com> writes:

>
> 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?
>
> Thanks,
> Shailendra
>

A similar problem comes up when you have to match astronomical coordinates. I
wrote a python + numpy function that is fast enough for my use cases - you might

http://bitbucket.org/nhmc/pyserpens/src/tip/coord.py

The matching function starts on line 166.

Disclaimer: I haven't looked at the kdtree code yet, that might be a better
approach.

Neil

```