- reckon: https://www.mathworks.com/help/map/ref/reckon.html
- nm2deg: https://www.mathworks.com/help/map/ref/nm2deg.html
- atan2d: https://www.mathworks.com/help/matlab/ref/atan2d.html
X & Y to LAT & LON
23 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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?
0 Commenti
Risposte (1)
Omega
il 13 Set 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);
fprintf('New Longitude: %.6f\n', newLon);
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!
0 Commenti
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!