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 件のコメント
Sam Chak
2022 年 3 月 21 日
Are you trying to plot a top view of the roads and indicate the height of each road?

Muhammad Qaisar Fahim
2022 年 3 月 21 日
採用された回答
その他の回答 (1 件)
Sam Chak
2022 年 3 月 21 日
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 件のコメント
Muhammad Qaisar Fahim
2022 年 3 月 21 日
Sam Chak
2022 年 3 月 21 日
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
2022 年 3 月 21 日
Sam Chak
2022 年 3 月 21 日
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);

Sam Chak
2022 年 3 月 21 日
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);

Sam Chak
2022 年 3 月 21 日
Is the road curved? We need you to confirm.
x = (6371).*cos(B).*cos(A);
y = (6371).*cos(B).*sin(A);
scatter(x, y)

カテゴリ
ヘルプ センター および File Exchange で Geographic Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!