How to make 2-D plot some points with Latitude, Longitude and Third value in Matlab?

5 ビュー (過去 30 日間)
Zahra Sdi
Zahra Sdi 2016 年 4 月 16 日
コメント済み: Dinibel Perez 2019 年 9 月 16 日
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
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
Dinibel Perez 2019 年 9 月 16 日
Hi!! I have a similiar problem... Could you solve it???? To plot TEC values

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

回答 (2 件)

Kuifeng
Kuifeng 2016 年 4 月 16 日
help contour

Alireza Alizadeh
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

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by