Calculate Distance from GPS coordinates
Afficher commentaires plus anciens
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
Réponse acceptée
Plus de réponses (2)
Mark Sherstan
le 14 Déc 2018
1 vote
MathWorks Support Team
le 11 Juil 2023
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 commentaire
Cg Gc
le 5 Août 2025
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.
Catégories
En savoir plus sur Coordinate Reference Systems dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!