Plotting 2 different color maps on one world map
3 件のコメント
採用された回答
Hi @Judy Wu,
You asked, “Is it possible for both of the axes to be on this world map projection (see below; worldmap([69, 79], [-167, -117]))?”
Please see my response to your comments below.
To achieve the desired outcome of overlaying both datasets on the specified world map projection, you need to make sure that both axes (ax1 and ax2) are created within the context of the world map coordinate system. Here is a refined version of your code that makes sure both datasets are plotted correctly on the world map projection:
% Load the .tif and .nc files A2 = imread('your_file.tif'); % Replace with your .tif file path R2 = maprefpost('your_file.tif'); % Replace with your .tif reference data_nc = ncread('your_file.nc', 'variable_name'); % Replace with your .nc file and variable
% Create a world map figure; worldmap([69, 79], [-167, -117]);
% Create first axes for the .tif file ax1 = axesm('MapProjection', 'mercator', 'Frame', 'on', 'Grid', 'on'); % Define map projection hold on; geoshow(ax1, A2, R2, 'DisplayType', 'surface'); colormap(ax1, 'bone'); % Apply first colormap colorbar(ax1); % Add colorbar for the first dataset
% Create second axes for the .nc file ax2 = axesm('MapProjection', 'mercator', 'Frame', 'on', 'Grid', 'on'); % Same projection hold on; geoshow(ax2, data_nc, 'DisplayType', 'surface', 'FaceAlpha', 0.2); % Adjust transparency colormap(ax2, 'winter'); % Apply second colormap colorbar(ax2); % Add colorbar for the second dataset
% Set the visibility of the axes set(ax1, 'Color', 'none'); % Make the background transparent set(ax2, 'Color', 'none'); % Make the background transparent
% Ensure both axes are displayed together in the same figure linkaxes([ax1 ax2]); % Link axes if necessary for synchronized zoom/pan
In the above refined code, the use of axesm allows you to specify a map projection (in this case, mercator) which is essential to make sure that both datasets are aligned correctly on a geographical representation. Using linkaxes helps synchronize zooming and panning between both datasets if required. Also, the FaceAlpha property remains set to allow visibility of overlapping areas between different datasets.
Use compatible coordinate reference systems (CRS) for your .tif and .nc files. Before plotting, I will advise to validate your geospatial data for any inconsistencies or missing values that may affect visualization.
For further guidance and information on the matlab functions mentioned in comments, please refer to
axesm
https://www.mathworks.com/help/map/ref/axesm.html
linkaxes
https://www.mathworks.com/help/matlab/ref/linkaxes.html?s_tid=doc_ta
By following these adjustments and considerations, you should be able to visualize both datasets effectively on a unified world map projection. If you have further questions or need additional assistance, feel free to ask!
5 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!