how to calculate the distance of a lat lon to the coastline?
조회 수: 6 (최근 30일)
이전 댓글 표시
hello, I want to find the distance from the lat lat station to the coastline. following my script, but there was an error that I did not understand, I thank anyone who provided advice and helped me.
lonlat = load ('lonlat.mat');%get lonlat allstasiun
coast = load('coast.dat');
% % Preallocate
coast_indexes = size(lonlat);
distancefromcoast = size(lonlat);
% % Find distance and corresponding coastal point
for i=1:1:numel(lonlat)
[dist, az] = distance(lonlat(i), lonlat(i), coast.lat, coast.long);
[distancefromcoast(i),coast_indexes(i)] = min(dist);
end
댓글 수: 3
Melih Can
2020년 9월 9일
Should be 'coast.mat' also distance('lonlat(i),lonlat(i)'... does'nt look appropriate
답변 (1개)
David Hill
2020년 1월 11일
Technically, you should use spherical trigonometry (great circle path) to determine the shortest distance. The algorithm is not difficult. You could solve my Cody problem: https://www.mathworks.com/matlabcentral/cody/problems/45180
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!