0

For example I have a dataset that looks like this

ID|latitude|longitude|lat        |lon
1  40.82696 -73.86721 49.82679   -73.86712
2  40.82696 -73.86721 49.82679   -73.86712 
3  40.81844 -7386649  40.81146   -73.92172

I would like to find a package say sf or any other spatial that takes latitude and longitude pair and find the difference between lat and lon pair with specified units which would allow me to create a miles or feet output.

user35131
  • 1,105
  • 6
  • 18
  • 2
    You can use `geosphere::distm()` to achieve this. See here: https://stackoverflow.com/questions/32363998/function-to-calculate-geospatial-distance-between-two-points-lat-long-using-r – Johnny Feb 18 '22 at 19:21
  • 1
    Depending on the accuracy required, you may also use (in `geosphere`) the `distHaversine`, `distVincentySphere`, or `distVincentyEllipsoid` functions (also mentioned in Johnny's link), with increasing accuracy and relative computation time. I believe all default to "meters", that's easily transformed to different units. – r2evans Feb 18 '22 at 19:23
  • does anyone know why I get all these distance columns when i export as .csv? – user35131 Feb 18 '22 at 20:14

0 Answers0