coordinates = [(-225.0, -299.5), (-150.0, 75.5), (0.0, 0.0), (225.0, 300.5)]
xy = (-222.4, -204.5)
What is the best way so that a given value xy can be compared to a 2D list of coordinates, and return the index number of the closest coordinate?
In this example, xy would be compared to the coordinates list and thus return the closest coordinate (-225.0, -299.5) or, more ideally, the index number 0.
I've tried researching for a method with itertools or numpy, but couldn't seem to understand how to get the result I want in my example.