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

9 views (last 30 days)
Zahra Sdi on 16 Apr 2016
Commented: Dinibel Perez on 16 Sep 2019
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
Dinibel Perez on 16 Sep 2019
Hi!! I have a similiar problem... Could you solve it???? To plot TEC values

Kuifeng on 16 Apr 2016
help contour

Alireza Alizadeh on 14 Aug 2018
Edited: Alireza Alizadeh on 14 Aug 2018
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
bearing = atan2(sin(lon2-lon1)*cos(lat2), cos(lat1)*sin(lat2)-sin(lat1)*cos(lat2)*cos(lon2-lon1));
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
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