How to plot a road along its height.

Actually the data I have has latitude(x) and longitude(y) of a road and also I have height of the road (z). Now I want to construct a plot which has shows height too and that height should be color coded. How can I do that ?

2 comentarios

Sam Chak
Sam Chak el 21 de Mzo. de 2022
Are you trying to plot a top view of the roads and indicate the height of each road?
Muhammad Qaisar Fahim
Muhammad Qaisar Fahim el 21 de Mzo. de 2022
Yes that is what I want. I copied a data in below comment which include longitude, latitude and height

Iniciar sesión para comentar.

 Respuesta aceptada

KSSV
KSSV el 21 de Mzo. de 2022

0 votos

Read about surf. It also depends on what data you have and how want to show up the plot. More help on sharing the data and showing your expectations.

7 comentarios

Muhammad Qaisar Fahim
Muhammad Qaisar Fahim el 21 de Mzo. de 2022
Here A is the longitude, Bis the latitude and C is the elevation. I have tried surf plot but it is not making sense.
KSSV
KSSV el 21 de Mzo. de 2022
Try plot3 with limiting axis to the range you want.
Muhammad Qaisar Fahim
Muhammad Qaisar Fahim el 21 de Mzo. de 2022
In Plot3 there is no color coding and it looks weired.
Muhammad Qaisar Fahim
Muhammad Qaisar Fahim el 21 de Mzo. de 2022
@KSSV What your opinion?
KSSV
KSSV el 21 de Mzo. de 2022
x = A;
y = B;
z = C ;
col = x; % This is the color, vary with x in this case.
surface([x x],[y y],[z z],[col col],...
'facecol','no',...
'edgecol','interp',...
'linew',2);
Now you need to change the view and limit the axis using axis. Read about view and axis
Muhammad Qaisar Fahim
Muhammad Qaisar Fahim el 21 de Mzo. de 2022
Yes I think its helping out. Thanks
KSSV
KSSV el 21 de Mzo. de 2022
Your data is huge, you need to restrict the data to a certain limit, plot and then see.

Iniciar sesión para comentar.

Más respuestas (1)

Sam Chak
Sam Chak el 21 de Mzo. de 2022
I guess you want to show something like this. Because the data is dense, it is not recommended to show the height of every point. But you can definitely adjust how and which particular point/region that you want to show the heights.
plot(A, B)
for t = 1:4379:numel(A)
text(A(t) + 0.0001, B(t) + 0.0001, ['(',num2str(C(t)),')'])
end

7 comentarios

Sam Chak
Sam Chak el 21 de Mzo. de 2022
Perhaps @KSSV can help on how to 'beautify' the plot and display the heights of the road.
Muhammad Qaisar Fahim
Muhammad Qaisar Fahim el 21 de Mzo. de 2022
Thanks Sam. Why is it on just a single line I need something like this? How can I do that? Assume I dont get lines but how do i even get dots? I need elevation to be color coded.
Sam Chak
Sam Chak el 21 de Mzo. de 2022
Okay, I'm trying to figure out what you want. The spatial data latitude and longitude indicate the position of each point on a 2D surface. Then you want the color gradient to represent the elevation of each point, isn it?
Muhammad Qaisar Fahim
Muhammad Qaisar Fahim el 21 de Mzo. de 2022
Yes exactly. You understood it correctly
I converted the longitude, latitude, elevation to Cartesian coordinates, and then used @KSSV's suggested code to plot it. Is this what you want?
x = C.*cos(B).*cos(A);
y = C.*cos(B).*sin(A);
z = C.*sin(B);
col = x; % This is the color, vary with x in this case.
surface([x x],[y y],[z z],[col col],...
'facecol','no',...
'edgecol','interp',...
'linew',2);
Wait. I think you need to consider the Earth radius (6371 km) in order to project the location of the points on the curved surface in Cartesian coordinates.
And then at each point, you want to show the elevation in the C.mat data using the color gradient. I think the z coordinate in not needed.
x = (6371).*cos(B).*cos(A);
y = (6371).*cos(B).*sin(A);
z = (6371).*sin(B);
Is the road curved? We need you to confirm.
x = (6371).*cos(B).*cos(A);
y = (6371).*cos(B).*sin(A);
scatter(x, y)

Iniciar sesión para comentar.

Categorías

Más información sobre Geographic Plots en Centro de ayuda y File Exchange.

Productos

Versión

R2022a

Etiquetas

Preguntada:

el 21 de Mzo. de 2022

Comentada:

el 21 de Mzo. de 2022

Community Treasure Hunt

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

Start Hunting!

Translated by