how to calculate the distance of a lat lon to the coastline?

7 ビュー (過去 30 日間)
surya
surya 2019 年 12 月 14 日
コメント済み: Melih Can 2020 年 9 月 9 日
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 件のコメント
Meg Noah
Meg Noah 2020 年 1 月 10 日
Please share 'lonlat.mat'
Melih Can
Melih Can 2020 年 9 月 9 日
Should be 'coast.mat' also distance('lonlat(i),lonlat(i)'... does'nt look appropriate

サインインしてコメントする。

回答 (1 件)

David Hill
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

Community Treasure Hunt

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

Start Hunting!

Translated by