9

My question is based upon this question. Using it I wrote below code where first set of coordinates are for LGA airport NY while second set of coordinates are for EWR airport NY. I get the answer 33713. Is that in miles or in kilometers? A quick google check says that the distance should be 33 miles (but it is not a straigh line/arc distance :( It is a distance by road). The package documentation says that the answers are in meters. Please clarify. Is this a good method to find the distance on Earth given 2 coordinates? How can I get answer in Miles?

library(geosphere)
distm (c(40.777250, -73.872610), c(40.6895, -74.1745), fun = distHaversine)
         [,1]
[1,] 33713.61
www
  • 38,575
  • 12
  • 48
  • 84
user2543622
  • 5,760
  • 25
  • 91
  • 159
  • Voting to close, there is no question here, only interpretation. The documentation is clear, and the conversion from meters to miles is trivial. – Benjamin May 25 '16 at 18:22

1 Answers1

11

Yes, it's giving you the answer in meters. To convert to miles:

> distm(c(40.777250, -73.872610), c(40.6895, -74.1745), fun = distHaversine)[,1] / 1609
[1] 20.95315

20.95 miles as the crow flies.

Edward R. Mazurek
  • 2,107
  • 16
  • 29