フィルターのクリア

Display netcdf data over specific country

4 ビュー (過去 30 日間)
David du Preez
David du Preez 2019 年 3 月 18 日
コメント済み: David du Preez 2019 年 11 月 4 日
I have a netcdf file containg data for a region over southern africa. I only want to plot the data over South Africa and not the rest of the region.
Using the borders function and changing the transparency I have almost got the map that I want except that the data is still displayed over the ocean. How can I mask out the ocean region
% Draw nc varibale on map of SA
ncfile = 'OMI-Aura_L3-OMUVBd_2004m1001_v003-2016m0525t164359.he5.nc';
long_uv = ncread(ncfile,'lon');
lat_uv = ncread(ncfile,'lat');
uvi = ncread(ncfile,'UVindex');
% Plot variable
[X,Y] = meshgrid(long_uv,lat_uv);
colormap jet
pcolor(X,Y,uvi');
shading interp
h= colorbar('horiz');
xlabel(h,'UVI');
hold on
% Plot SA map over variable
[lat,lon] = borders('south africa');
pgon = polyshape(lon,lat,'simplify',false);
plot(pgon,'FaceColor','none','FaceAlpha',0)
clear lat lon pgon
hold all
% Zimbabwe
[lat,lon] = borders('zimbabwe');
pgon = polyshape(lon,lat,'simplify',false);
plot(pgon,'FaceColor','white','FaceAlpha',1)
clear lat lon pgon
hold all
% Nambia
[lat,lon] = borders('Namibia');
pgon = polyshape(lon,lat,'simplify',false);
plot(pgon,'FaceColor','white','FaceAlpha',1)
clear lat lon pgon
hold all
% Botswana
[lat,lon] = borders('botswana');
pgon = polyshape(lon,lat,'simplify',false);
plot(pgon,'FaceColor','white','FaceAlpha',1)
clear lat lon pgon
hold all
% Mozambique
[lat,lon] = borders('mozambique');
pgon = polyshape(lon,lat,'simplify',false);
plot(pgon,'FaceColor','white','FaceAlpha',1)
clear lat lon pgon
% Lesotho
[lat,lon] = borders('lesotho');
pgon = polyshape(lon,lat,'simplify',false);
plot(pgon,'FaceColor','white','FaceAlpha',1)
clear lat lon pgon
% Swaziland
[lat,lon] = borders('swaziland');
pgon = polyshape(lon,lat,'simplify',false);
plot(pgon,'FaceColor','white','FaceAlpha',1)
clear lat lon pgon
  2 件のコメント
BN
BN 2019 年 11 月 4 日
I have a same problem bro, did you find any solution BTW?
David du Preez
David du Preez 2019 年 11 月 4 日
Yes. Get the latitudes and longtiudes of the countries using the borders function and then look at this answer https://ch.mathworks.com/matlabcentral/answers/486421-change-color-outside-region-of-polyshape

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeNetCDF についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by