필터 지우기
필터 지우기

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 CenterFile Exchange에서 NetCDF에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by