0

I have 20,000 coordinates (which consist of latitude and longitude), and I need to calculate the distance between each of these 20,000 coordinates (so the result will be a table of 20000 * 20000 cells, and each cell shows the distance between each coordinate).

The code that I use for finding the distance in Python is the following:

geopy.distance.geodesic(coord1, coord2).miles

I can do this using for-loops, but I want to avoid for-loops. Can someone please let me know how I can perform pair-wise operation to find the distance between all coordinates without using for-loops?

Francesco - FL
  • 603
  • 1
  • 4
  • 25
alexorbit
  • 1
  • 1
  • You want to apply Balltree/KDTree with haversine metric. Please provide some sample code with toy data, and your language of choice – Willem Hendriks Mar 23 '23 at 11:09

0 Answers0