Overlaying shapefile over 3D plot
조회 수: 3 (최근 30일)
이전 댓글 표시
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
답변 (1개)
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
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 Exchange에서 NetCDF에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!