Clear Filters
Clear Filters

X & Y to LAT & LON

25 views (last 30 days)
BioZ
BioZ on 9 Feb 2022
Answered: Divit on 13 Sep 2023
Hi, Say we start at origin = [LAT LON] and travel 1000m East and 800 m South, now I would like to find new LAT LON.
Is there a specific function in matlab mapping toolbox for that, if not what would be the best way of implementing it?
Perhaps by use of Great Circle?

Answers (1)

Divit
Divit on 13 Sep 2023
Hi Bio,
I understand that you would like to know the new coordinates for latitude and longitude when you know the distance and directions from the old coordinates.
You can achieve this with the help of “reckon”, “nm2deg” and “atan2d” functions present in “MATLAB Mapping Toolbox”.
Here’s an example code for the same:
% Starting coordinates
startLat = 0.0; % Replace with your actual starting latitude
startLon = 0.0; % Replace with your actual starting longitude
% Distances traveled (in meters)
distanceEast = 1000; % 1000 meters East
distanceSouth = 800; % 800 meters South
% Convert distances from meters to nautical miles
distanceEast_nm = distanceEast / 1852; % 1 nautical mile = 1852 meters
distanceSouth_nm = distanceSouth / 1852;
displacement_nm = sqrt(distanceEast_nm^2 + distanceSouth_nm^2);
% Convert spherical distance from nautical miles to degrees
arclen = nm2deg(displacement_nm);
% Calculate the azimuth (bearing angle)
az = atan2d(distanceEast, distanceSouth);
% Ensure the result is between 0 and 360 degrees
if az < 0
az = az + 360;
end
% Calculate new coordinates using the reckon function
[newLat, newLon] = reckon(startLat, startLon, arclen, az);
% Display the new coordinates
fprintf('New Latitude: %.6f\n', newLat);
New Latitude: 0.007195
fprintf('New Longitude: %.6f\n', newLon);
New Longitude: 0.008993
Alternatively, you could use the traditional approach which uses Haversine formula based on the Great Circle and write your own function for it.
To know more you can refer to the following documentation links:
I hope it helps!

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!