How to find distance from the latitude and longitude of two locations?

后端 未结 12 2407
情歌与酒
情歌与酒 2020-11-29 02:40

I have a set of latitudes and longitudes of locations.

  • How to find distance from one location in the set to another?
  • Is there a f
12条回答
  •  南方客
    南方客 (楼主)
    2020-11-29 03:17

    Here's one: http://www.movable-type.co.uk/scripts/latlong.html

    Using Haversine formula:

    R = earth’s radius (mean radius = 6,371km)
    Δlat = lat2− lat1
    Δlong = long2− long1
    a = sin²(Δlat/2) + cos(lat1).cos(lat2).sin²(Δlong/2)
    c = 2.atan2(√a, √(1−a))
    d = R.c 
    

提交回复
热议问题