I want to calculate the distances between some locations in an Excel file using longitude and latitude,with R Software, i've never tried to do it before. If someone can help me, it would be very good.
Many Thanks in advance .
I want to calculate the distances between some locations in an Excel file using longitude and latitude,with R Software, i've never tried to do it before. If someone can help me, it would be very good.
Many Thanks in advance .
Try this to get distance in meters:
acos(sin(lat1)*sin(lat2) + cos(lat1)*cos(lat2)*cos(lon2-lon1)) * 6371000
Example : Distance between London (lat=52, lng=0) and Mumbai (lat=19, lng=72) is approx 8000 Kms
> acos( sin(19)*sin(52) + cos(19)*cos(52)*cos(72-0) ) * 6371000
[1] 8041318
Seems to be correct.
Reference: http://www.movable-type.co.uk/scripts/latlong.html