title: How can I remove too close points in a list
body: <p>I have a list of points with x,y coordinates:</p>
  
  <pre><code>List_coord=[(462, 435), (491, 953), (617, 285),(657, 378)]
  </code></pre>
  
  <p>This list lenght (4 element here) can be very large from few hundred up to 35000 elements.</p>
  
  <p>I want to remove too close points by threshold in this list.
  note:Points are never at the exact same position.</p>
  
  <p>My current code for that:</p>
  
  <pre><code>while iteration&lt;5:
    for pt in List_coord:
      for PT in List_coord:
          if (abs(pt[0]-PT[0])+abs(pt[1]-PT[1]))!=0 and abs(pt[0]-PT[0])&lt;threshold and abs(pt[1]-PT[1])&lt;threshold:
           List_coord.remove(PT)
    iteration=iteration+1
  </code></pre>
  
  <p>Explication of my terrible code :) :</p>
  
  <ul>
  <li>I check if the very distance is 0 then it means that i am comparing
  the same point </li>
  <li>then i check the distance in x and in y..</li>
  <li>Iteration:
  I need few iterations to avoid missing one remove because the list change inside the loop itself...</li>
  </ul>
  
  <p>This code is working but it is a very low process!</p>
  
  <p>I am sure there is another method much easier but i wasn't able to find even if some allready answered questions are close to mine..</p>
  
  <p>note:I would like to avoid using extra library for that code if it is possible</p>