![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/525674/image.png)
Finding LAT LONG inside a circle of a given LAT LONG .
3 次查看(过去 30 天)
显示 更早的评论
I have a LAT LONG (point A). I have another set of LAT LONG. I want to find LAT LONG points within 5km radius of point A.
How can I do that?
0 个评论
采纳的回答
Bruno Luong
2021-2-20
编辑:Bruno Luong
2021-2-20
% Random data
lonA=rand*360;
latA=rand*180-90;
n = 10000;
lonP=rand(1,n)*360;
latP=rand(1,n)*180-90;
earthradius = 6357;
rA = 1000; % distance from A
[xA,yA,zA] = sph2cart(deg2rad(lonA),deg2rad(latA),1);
[x,y,z] = sph2cart(deg2rad(lonP(:)),deg2rad(latP(:)),1);
P = [x,y,z];
A = [xA,yA,zA];
% W. Kahan method
alpha = 2*atan(vecnorm(A-P,2,2) ./ vecnorm(A+P,2,2));
inrA = abs(alpha) <= rA/earthradius; % logical array, 1 if the distance from A is <= rA
close all
hold on
plot3(xA,yA,zA,'r+', 'Linewidth', 3);
plot3(x(inrA),y(inrA),z(inrA),'k.');
plot3(x(~inrA),y(~inrA),z(~inrA),'.','Color',0.8+[0 0 0]);
axis equal
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/525674/image.png)
更多回答(1 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!