X & Y to LAT & LON

23 次查看(过去 30 天)
BioZ
BioZ 2022-2-9
回答: Omega 2023-9-13
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?

回答(1 个)

Omega
Omega 2023-9-13
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!

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by