Display netcdf data over specific country
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (0)
Voir également
Catégories
En savoir plus sur NetCDF dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!