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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With