I'm trying to calculate the distance between two coordinates (40.777250, -73.872610) and (40.6895, -74.1745)
.
Using distm in R gives the following result:
> distm (c(40.777250, -73.872610), c(40.6895, -74.1745), fun = distHaversine)
33713.61
When I use Excel to calculate the distance with the following function
6378134 * ACOS(COS(RADIANS(90-40.777250)) *COS(RADIANS(90-40.6895)) +SIN(RADIANS(90-40.777250)) *SIN(RADIANS(90-40.6895)) *COS(RADIANS(-73.872610-(-74.1745))))
the answer is 27274.49199
.
I'm wondering why these two methods give a different answer and whether I'm doing something wrong. I tried an online coordinate distance calculator and it gives the same answer as my excel function.