I have a list of lat/lon coordinates and I would like to find the most common locations. Is there a built in function for this?
Thank you.

 채택된 답변

Star Strider
Star Strider 2020년 11월 4일

0 개 추천

Try this:
M = randi(5, 25, 2); % Create ‘LatLon’ Data
[Mu,~,idx] = unique(M, 'rows'); % Unique Rows
Tally = accumarray(idx, (1:numel(idx)).', [], @(x) {M(x,:)}); % Calculate Frequencies, Return Pairs By Group
pairs = cellfun(@(x)size(x,1), Tally); % Recover ‘LatLon’ Pairs
[~,ixs] = sort(pairs, 'descend'); % Sort Them
Result = table(Mu(ixs,:),pairs(ixs), 'VariableNames',{'LatLon','Frequency'}); % Output Table Of Pairs & Frequencies
I did my best to comment-document it. Use your own latitude & longitude coordinates for ‘M’. It may be necessary to use uniquetol with the 'ByRows' option if the coordinates are not exactly the same.

댓글 수: 2

Erick Koenig
Erick Koenig 2020년 11월 4일
Awesome! works perfectly. That's exactly what I was looking to do. Thank you.
Star Strider
Star Strider 2020년 11월 4일
Thank you! As always, my pleasure!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터 및 File Exchange에서 Logical에 대해 자세히 알아보기

제품

태그

질문:

2020년 11월 4일

댓글:

2020년 11월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by