How to make 2-D plot some points with Latitude, Longitude and Third value in Matlab?
조회 수: 2 (최근 30일)
이전 댓글 표시
Hi All,
I have 3 vectors, v1=Latitude, v2=Longitude and v3=value (like deformation). I want to make a 2-D plot that shows each point with it's coordinate in lat and lon, and shows the third value as a colour for each point.
Could you please let me know what the best way is to do that?
Thanks, Zahra
댓글 수: 4
Sivakandan Mani
2019년 6월 4일
Hi Zahra,
I have similar kind of data, latitude, longitude and total electron content (TEC),
in the form of three arrays, I want to plot in 2D. I am unable to use either countour or pcolor becuase my TEC is only in the form of arry not in matrix.
Could you help me in this regards. I hope you might found answer for your trouble.
Thanks in advance,
Siva
Dinibel Perez
2019년 9월 16일
Hi!! I have a similiar problem... Could you solve it???? To plot TEC values
답변 (2개)
Alireza Alizadeh
2018년 8월 14일
편집: Alireza Alizadeh
2018년 8월 14일
First of all you need an origin for the locations. I assumed that the first point is located at (X,Y) = (0,0). Then, you need to obtain the distances and bearing angles of all points with respect to the the first point using the following functions:
if true
function bearing = Bearing_Angle(lat1, lon1, lat2, lon2)
% convert decimal degrees to radians
lon1 = deg2rad(lon1);
lat1 = deg2rad(lat1);
lon2 = deg2rad(lon2);
lat2 = deg2rad(lat2);
bearing = atan2(sin(lon2-lon1)*cos(lat2), cos(lat1)*sin(lat2)-sin(lat1)*cos(lat2)*cos(lon2-lon1));
bearing = rad2deg(bearing);
bearing = mod((bearing + 360),360);
end
end
if true
function meter = haversine(lat1, lon1, lat2, lon2)
% https://andrew.hedges.name/experiments/haversine/
% convert decimal degrees to radians
lon1 = deg2rad(lon1);
lat1 = deg2rad(lat1);
lon2 = deg2rad(lon2);
lat2 = deg2rad(lat2);
dlon = lon2 - lon1;
dlat = lat2 - lat1;
% haversine formula
a = sin(dlat/2)^2 + cos(lat1) * cos(lat2) * sin(dlon/2)^2;
c = 2 * asin(sqrt(a));
km = 6367 * c;
meter = km*1000;
ft = km*3280;
miles = ft/5280;
end
end
Now, you can try the following code to obtain 2D locations and plot the points:
if true
Locations_XY = zeros(N,2);
Locations_XY(1,:)= [0 0];
for n = 2 : N
theta_deg = Bearing_Ang(1,n);
theta = (2*pi*theta_deg)/360;
d = Dist(1,n);
Locations_XY(n,:)= [d*sin(theta) d*cos(theta)];
end
figure
hold on
box on
for n = 1 : N
plot(Locations_XY(n,1),Locations_XY(n,2),'sb','markersize',40,'markerfacecolor','c');
text(Locations_XY(n,1),Locations_XY(n,2), num2str(n),'FontSize',12,'HorizontalAlignment','center');
end
end
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!