How to overlap several maps?
조회 수: 5 (최근 30일)
이전 댓글 표시
Hi all,
I wrote two codes (code 1 and code 2) below to produce the pictures attach within htis question. I would like to add on th figure showing the vessel density (vessel density.png file; code 1), the limit of the coastal area of the United Kingdom (and associated islands) and Ireland using M_map (also attached here: UK.jpg; code 2). does someone how can I write one code to have both on it? Also, if someone knows how to fill the land (inside the coastal limit) in white to make it look better that would be also great.
Regards
%% Code 1
% assign the path to your working directory:
cd ('E:\Data_emodnet_fisheries\Vessel_density\');
load Average.mat % Matrice representing the positon of boat in the sea
imshow(Average,Colormap=turbo);
limits = [0,3];
c = colorbar;
set(gca,'clim',limits([1,end]));
c.Label.String = 'Vessel density (h/m2/month)';
saveas(gcf,'Vessel_density.png')
%% Code 2
% assign the path to your working directory:
cd ('E:\publi\Waiting-room\Matt_paper_hydrogen\figure_Matt\new\gshhg-bin-2.3.7(1)\');
% add path to TelemacTolls functions (i.e. to read in telemac files into MATLAB):
addpath ('C:\Matlab_download\m_map1.4\m_map\');
workingFolder = tempdir;
latlim = [48 63];
lonlim = [-12 3];
S = gshhs('gshhs_h.b', latlim, lonlim);
levels = [S.Level];
L1 = S(levels == 1);
figure
plot ([L1.Lon],[L1.Lat], '-b');
xlim([-11 3]);
ylim([49 61]);
댓글 수: 0
채택된 답변
Kevin Holly
2022년 3월 15일
편집: Kevin Holly
2022년 3월 15일
You could edit the colormap to make the land white.
figure
image
colorbar
colormap turbo
figure(2)
image
colorbar
cmap = turbo;
cmap(1:4,:)=ones(4,3);
colormap(cmap)
In your case, you can do the following:
cmap = turbo;
cmap(1:4,:)=ones(4,3);
imshow(Average,Colormap=cmap);
You may need to adjust the range in which the color is white ([1 1 1]).
As for overlaying the plot on the image. You could use "hold on" as such:
hold on
plot ([L1.Lon],[L1.Lat], '-b');
xlim([-11 3]);
ylim([49 61]);
The resolution of the image (x pixels vs y pixels) and the coordinates of the plot (latitude vs longitude range) may not match. You may need to scale it.
댓글 수: 3
Kevin Holly
2022년 3월 16일
If you are having difficulties lining up the axes. You could create two different axes and make the background and axes of the axes with the plot invisible.
ax1 = axes;
img = image;
colorbar
cmap = turbo;
cmap(1:4,:)=ones(4,3);
colormap(cmap)
ax2 = axes;
plot(50*rand(7,7))
ax2.Color='none';
ax2.Position = ax1.Position;
axis off
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Orange에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!