title: Efficiently find closest point from another point
body: <p>I have a list A of coordinates (latitute, longitute in decimal form) with ~10.000 points and a second list B of coordinates of the same type with ~1 million points. </p>
  
  <p>I want to find the closest point in list A for each element in list B. </p>
  
  <p>What I have already done is create the cartesian product of the two lists and find the distance of all the combinations using the haversine formula.</p>
  
  <p>Then I get the points in list A which have the minimum distance for each point in list B.</p>
  
  <p>Since the total combinations are more than 10 billion, the time taken to calculate the distances is too long. </p>
  
  <p>Is there a way to ensure that every point in list B will match a point in list A but also improve the performance?</p>