Overlaying shapefile over 3D plot
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
Harsh
el 27 de Jun. de 2023
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 comentarios
Harsh
el 5 de Jul. de 2023
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!
Ver también
Categorías
Más información sobre NetCDF en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!