Calculate Distance from GPS coordinates

99 次查看(过去 30 天)
I have 2 columns in a spreadsheet representing the latitude and longitude.
How can I calculate the distance for between the the gps coordinates (eg distance between row 1 and row 2) using the formula
d=ACOS(cos(RADIANS(90-Lat1))*cos(RADIANS(90-Lat2))+sin(RADIANS(90-Lat1))* sin(RADIANS(90-Lat2))*cos(RADIANS(Lon1-Lon2)))* 3958.76
Latitude Longitude
33.47914 -88.7943
33.47914 -88.7943
33.47915 -88.7943
33.47917 -88.7943

采纳的回答

Walter Roberson
Walter Roberson 2018-12-15
编辑:Walter Roberson 2018-12-15
With vector Lat and Lon, and assuming you want the distance between adjacent gps points (as opposed to the distance of each point to each other point)
d = acos(cosd(90-Lat(1:end-1)) .* cosd(90-Lat(2:end)) + sind(90-Lat(1:end-1)) .* sind(90-Lat(2:end))) .* cosd(Lon(1:end-1)-Lon(2:end)) * 3958.76;

更多回答(2 个)

Mark Sherstan
Mark Sherstan 2018-12-14
Look at this function here.

MathWorks Support Team
Tthe distance function in Mapping Toolbox is an option. This function has the benefit of being able to calculate the geodesic distance for a given Earth ellipsoid model, such as the WGS84 model which is used for GPS coordinates. For example:
lat = [33.47914 33.47914 33.47915 33.47917];
lon = [-88.7943 -88.7943 -88.7943 -88.7943];
% Use WGS84 ellipsoid model
wgs84 = wgs84Ellipsoid;
% Calculate individual distances
d1 = distance(lat(1),lon(1),lat(2),lon(2),wgs84);
d2 = distance(lat(2),lon(2),lat(3),lon(3),wgs84);
d3 = distance(lat(3),lon(3),lat(4),lon(4),wgs84);
  1 个评论
Cg Gc
Cg Gc 2025-8-5
I have been using this function, but my points are really close, so I am getting a distance of 0.1209. This is fine, but what are the units on this number? km? miles? feet? inches? I know how far away my points are in km, but with thousands of points and further calculations to make, I would rather do the calculations in a loop. In order to do this, I need to know the units of the answer to the distance function. It says it is degrees, but that isn't helpful for when you need to convert that to distance on the ground.

请先登录,再进行评论。

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by