Closets points to a point collection?




im trying to find the closest point to a collection point using the “brute force” method of finding all distances to all points (cross product lacing) and get the minimum (sort distances and take first), but now i dont know how to take the points that correspond to that minimum distance. I think i need to use “sort by key” to synchronously sync the distance list and the second point lists, but t i dont know how to use it and i couldnt open examples files in



any help? or maybe another way to find closest points to a point collection?



here screen and file:






Thanks to Steve examples, I create two custom closest point nodes (google translate link) and here a practical example with solar radiation analysis (again a google translate link, sorry).

Thanks Steve!!


So what you want to do is, given a list of XYZs, create a Line between each XYZ and the closest XYZ from a separate collection of XYZs.

First, make a Custom Node that, given a single XYZ and a collection of XYZs, produces a line between the single XYZ and the closest XYZ from the collection.

Then you can use this node as an input to Map in order to process a list of points:


Hi Steve, thanks for answer :D

i didn't know that you can use custom nodes as functions so i want to say thanks for that.

unfortunately your solution its not working for what i want or i dont know how to use it.

In the screenshot that I posted, i got a list of minimum distances for every point in the first XYZ point list. I need to find the corresponding point in the second list that produce that minimum distance.

I thought that the problem was the cross product lacing option in the node but its not working with list minimum (its looks that the list minimum dont work with sublist?):

Then i tried to create my own node with the "cross product distance" -> sort sublist -> get minimum distance (first index on every sublist). The node itself works, but i cant use it as function except with map node, but its not given me the points coordinates, just distances (its look like the map node applied the function and dont remap/copy/transform the index/list as i thought it would, my bad).

Here a screenshot:

maybe its my bad english... so here's a screenshot of what i'm trying to do (grid connected to closest point):


Basically, you want to find the minimum value in a list of XYZs, where the "minimum" is found by comparing the minimum distance between an XYZ in the list and a completely separate list of XYZs.

The first step is to create a node that, given a single XYZ and a collection of XYZs, finds the smallest distance between any XYZ in the collection and the single XYZ. This is done by lacing with the XYZ Distance node, and then using the List Minimum node to find the smallest result. Note that here a Key Mapper function (the f(x) input) is not necessary because we're dealing with numbers, which are inherently orderable.

Now that we have this node, we can use it with List Minimum as a Key Mapper. This will take a list of XYZs, feed each into the Key Mapper, and return the XYZ that produced the smallest key.