how to plot country borders in regional data

41 次查看(过去 30 天)
I have a netCDF file in which I have a variable to plot at 12 Km grid spacing. The domain is regional and contains 3 countries i.e. Norway, Sweden, and Finland.
Is there a way to draw country borders?
Example plot is attached.
LST_JJActl = ncread('/Volumes/YKMac/EnsAvg_NSF12KP3CTL_JJA_DTM.nc','LST');
pft=ncread('/Volumes/YKMac/NetCDF_Inputdata_P3/NSF12KP3CTL_CLM45_surface.nc','pft_2d');
nt=pft(:,:,3); bt=pft(:,:,9);
NETx=nan(size(LST_JJActl,1),size(LST_JJActl,2)); BDTx=nan(size(LST_JJActl,1),size(LST_JJActl,2));
NETx(1:end,1:end)=nt(2:end-2,2:end-2); BDTx(1:end,1:end)=bt(2:end-2,2:end-2);
NET=NETx*0.01; BDT=BDTx*0.01;
PFTtot=(NET+BDT); % Sum of NET and BDT pft fraction to apply on variables of grid level
x0=10; y0=10; width=1200; height=600;
figure(1);
set(gcf,'units','points','position',[x0,y0,width,height]);
%$*********************** PFT fraction ***********************$%
subplot(1,2,1);
h11=imagesc(rot90(NETx));axis on;grid; set(h11,'alphadata',~isnan(rot90(NETx)));
set(gca,'color', [0.5 0.5 0.5]); caxis([0 100]); colormap(bluewhitered(256));
yticklabels({'69','67','65','63','61','59','57','55'});
xticklabels({'0','5','10','15','20','25','30','35'});
ylabel('Lat');xlabel('Lon'); title('NET','fontsize',14);
subplot(1,2,2);
h12=imagesc(rot90(BDTx));axis on;grid; set(h12,'alphadata',~isnan(rot90(BDTx)));
set(gca,'color', [0.5 0.5 0.5]); caxis([0 100]); colormap(bluewhitered(256));
yticklabels({'69','67','65','63','61','59','57','55'});
xticklabels({'0','5','10','15','20','25','30','35'});
ylabel('Lat');xlabel('Lon'); title('BDT','fontsize',14);
hp1 = get(subplot(1,2,2),'Position');
hc1 = colorbar('Location','Manual','Position', [hp1(1)-0.062 hp1(2)+0.024 hp1(3)-0.32 hp1(4)-0.06]);
title(hc1,'%');
sgtitle('Fraction of PFT in RegCM+CLM, NET and BDT','fontweight','bold','fontsize',16);
set(gcf,'inverthardcopy',false);
saveas(gcf,'/Volumes/YKMac/Figures_P3/FigP3_SI4_PFTfract.png');
Thanks.

回答(1 个)

KSSV
KSSV 2022-3-8
You may download your required countries boundary shape file from this link: https://gadm.org/download_country.html
You can read the data using shaperead and then plot.
  7 个评论
KSSV
KSSV 2022-3-9
编辑:KSSV 2022-3-9
It looks like you are giving wrong name for the shape file. Please check.
S = shaperead('gadm40_NOR_1.shp') ;
S = [[S.X]' [S.Y]'];
plot(S(:,1),S(:,2))
Yogesh Kumkar
Yogesh Kumkar 2022-3-9
Thanks, I could plot the borders of gdam40_NOR_0.shp, SWE, and FIN.
Looks good but, it does not overlay on my variable. May be something about projection and resolution I should do? The data I have is at 12 Km and at rotated mercator projection. Is there any way to exactly overlay the borders on variable?
N = shaperead('gadm40_NOR_0.shp') ;
S = shaperead('gadm40_SWE_0.shp') ;
F = shaperead('gadm40_FIN_0.shp') ;
figure(4);
plot(N.X, N.Y','k'); hold on;
plot(S.X, S.Y','k'); hold on;
plot(F.X, F.Y','k'); hold on;
title('Domain: Norway, Sweden, Finland','fontsize',14);
set(gcf,'inverthardcopy',false);
saveas(gcf,'/Volumes/YogeshKumkarMac/PAPER_3/Figures_P3/DomainNSF.png');

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Legend 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by