Hi,
I’m trying to find a list of points within range of given co-ordinates, using NearestNeighbours
using NearestNeighbors
coords = [0. 1
0 1]
balltree = BallTree(coords)
rsearch = 1.0
points = [0.5, 0.5]
idxs = inrange(balltree, points, rsearch, true) # shows [1, 2] as expected
but if I have multiple points
points = [0.5 1.5
0.5 1.5]
idxs = inrange(balltree, points, rsearch, true) # shows [[1, 2], [2]] as expected
But I don’t want to revisit indices in the tree already visited, if it is already within range of a point. So what I want is either of
idxs = unique(vcat(inrange(balltree, points, rsearch, true)...)) # provides [1, 2]
idxs = unique(reduce(vcat, inrange(balltree, points, rsearch, true))) # provides [1, 2]
But this concatenation is expensive. Is there a way to get around this? Is it possible to skip a tree co-ordinate if it has already been visited and just provide a vector of indices? I understand you can do this with knn
but not with balltree
.
Thanks