Fill below the 3D terrain data
6 ビュー (過去 30 日間)
古いコメントを表示
A=imread('appRasterNEDAPIService1708354512850-756880040.tif');
X=1:324;
Y=1:194;
[X,Y]=meshgrid(X,Y);
surf(X,Y,A)
Hello. I have this terrain data. The size of A matrix is 194x324 and contain elevation data. I want to fill below the terrain from the elevation of the data to the 0 (mean sea level). I use fill code
hFill = fill3(X, Y, A, patchColor, 'LineWidth', 1, 'EdgeColor', patchColor, ...
'FaceAlpha', 0.5);
However, it only fill below the surface with thin layer. I try to fill from the elevation to the 0 (mean sea level).
Thank you,
0 件のコメント
採用された回答
Tejas
2024 年 9 月 17 日
Hello Burak,
To fill the terrain from the elevation data down to mean sea level, you can create polygons that act like vertical planes or walls. These polygons start at the terrain surface and extend down to the z-plane at 0, which represents sea level.
Here is a code snippet demonstrating how this can be achieved:
patchColor = [0.5, 0.5, 0.5]; % Gray color
for i = 1:size(A, 2)
x = [X(:, i); flipud(X(:, i))]; % x cordinates for ith polygon
y = [Y(:, i); flipud(Y(:, i))]; % y cordinates for ith polygon
z = [zeros(size(A, 1), 1); flipud(A(:, i))];
fill3(x, y, z, patchColor, 'EdgeColor', 'none', 'FaceAlpha', 0.5);
end
Below is a screenshot of the output using sample data, showing how the terrain will appear:
For a better understanding of this solution, refer to the documentations below:
5 件のコメント
Tejas
2024 年 9 月 24 日
Hi Burak,
The issue arises because the 'hold' function has not been used. This causes the polygon plot for a column of matrix A to overwrite the existing plot. For more details on the 'hold' function, refer to this documentation: https://www.mathworks.com/help/releases/R2023b/matlab/ref/hold.html
Try this code snippet:
load("terrain.mat");
% Plot the terrain surface
figure;
surf(X, Y, A);
hold on;
patchColor = [0.5, 0.5, 0.5]; % Gray color
for i = 1:size(A, 2)
x = [X(:, i); flipud(X(:, i))]; % x cordinates for ith polygon
y = [Y(:, i); flipud(Y(:, i))]; % y cordinates for ith polygon
z = [zeros(size(A, 1), 1); flipud(A(:, i))];
fill3(x, y, z, patchColor, 'EdgeColor', 'none', 'FaceAlpha', 0.5);
end
% Adjust plot settings
xlabel('X');
ylabel('Y');
zlabel('Elevation');
title('3D Terrain with Filled Base');
view(3);
axis tight;
hold off;
Here is a screenshot of the output:
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Spline Postprocessing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!