フィルターのクリア

Overlaying shapefile over 3D plot

3 ビュー (過去 30 日間)
shravani banerjee
shravani banerjee 2023 年 6 月 23 日
コメント済み: Harsh 2023 年 7 月 5 日
How to overlay my shapefile over my 3D plot (either at the base or at the top). I tried with geoshow, but my shapefile is not overlaying over my 3D plot, its rather plotted far from my 3D plot. I have tried the following code. This is my data ( https://drive.google.com/file/d/1Y4LXTvoBl5GfHlZ-sYIcQJvM1KrWI3nD/view?usp=sharing )
file = 'MERRA2_400.inst3_3d_aer_Nv.20150525.SUB.nc';
lat = ncread(file, 'lat');
lon= ncread(file,'lon');
lev= ncread(file,'lev');
DMR= ncread(file,'DU002');
S = shaperead('India_country.shp');
% Mask the data based on shapefile region
[data_cropped] = maskregion(lon, lat, DMR, S);
% Create a meshgrid for plotting
[x, y, z] = meshgrid(lat, lon, lev);
% Plot the masked data
figure;
pcolor3(x, y, z, data_cropped);
% Overlay shapefile on the plot
hold on;
geoshow(S, 'X', 'Y', 'DisplayType', 'line', 'Color', 'red');
grid on
colormap('jet')
colorbar
%clim([0 1*10^-7])
set(gca, 'clim', [0 1.2*10^-7]);
alpha(.05)
xlim([20 26])
ylim([75 85])
zlim([42 72])
set(gca, 'ZDir', 'reverse');
set(gca,'YDir', 'reverse');
  2 件のコメント
Kautuk Raj
Kautuk Raj 2023 年 6 月 27 日
Please share the file, if possible.
shravani banerjee
shravani banerjee 2023 年 6 月 27 日
I have attached the link of the data in the code.

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

回答 (1 件)

Harsh
Harsh 2023 年 6 月 27 日
Upon inspecting your code, I believe that the problem is with the latitude and longitude values for meshgrid function. Latitude is the y-axis value and longitude is the x-axis value.
[x, y, z] = meshgrid(lon, lat, lev);
You can check the documentation for meshgrid for more clarity - https://in.mathworks.com/help/releases/R2022b/matlab/ref/meshgrid.html?s_tid=doc_ta
Please let me know if this solution works for you !
  2 件のコメント
shravani banerjee
shravani banerjee 2023 年 6 月 27 日
Actually my DMR variable itself is arranged in this way. You can find the attached data in the code.
Harsh
Harsh 2023 年 7 月 5 日
The meshgrid function and its argument structure is mentioned in the MathWorks documnetation page - https://in.mathworks.com/help/releases/R2022b/matlab/ref/meshgrid.html?s_tid=doc_ta.
I understand that you have a problem that your DMR data is arranged in a certain way and that is the reason for the issue. I would recommend you to break down your DMR data and maybe pass the arguments in the order mentioned in the documentation for the expected results.
Thanks!

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

カテゴリ

Help Center および File ExchangeNetCDF についてさらに検索

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by