[Numpy-discussion] "Match" two arrays
Charles R Harris
Thu Apr 1 00:06:04 CDT 2010
On Wed, Mar 31, 2010 at 9:24 PM, Shailendra <email@example.com>wrote:
> Hi All,
> I want to make a function which should be like this
> 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)
> (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...
More information about the NumPy-Discussion