What is wrong with my geopy great circle distance computation?

224 Views Asked by At

I want to compute the distance (in km) using geopy library between two points defined by their respective (lat, lon) coordinates.

My code

from geopy.distance import great_circle

# lat, lon
p1 = (45.8864, -7.2305)
p2 = (46.2045, -7.2305)

# distance in km
great_circle(p1, p2).km
>>> 35.371156132664765

To check above results, I used the tool available here: https://www.movable-type.co.uk/scripts/latlong.html but the two outputs do not match.

enter image description here

The output of my code is 35.371156132664765 though the above tool returns a distance of 15.41 km. How come the results are different ?

1

There are 1 best solutions below

0
Mohit Mehlawat On BEST ANSWER

Your calculation for the points p1 and p2 is wrong, you need to convert the minutes and seconds into degree correctly. Otherwise the code works prefectly.