I have gridded data between -40°S 0°S to 10°E to 45°E. I have manged to plot this data and add the borders of the countries over it. How can I mask the data that is plotted over the oceans. I only want to see the data over the land.

5 Kommentare

darova
darova am 20 Okt. 2019
Can you exaplain more? You want just background?
I plotted the gridded data and then added the borders with the countries that I am interested in
% Gridded data
pcolor(X,Y,uvi_mean');
shading interp
colormap jet
hold on
% used [lat lon] = borders('countries');
pgon = polyshape(lon,lat,'simplify',false);
plot(pgon,'FaceColor','none','edgecolor','k','facealpha',1)
I have attached a figure that I have so far. Now I only wanted the data to be displayed over land
jonas
jonas am 20 Okt. 2019
Easily done with inpolygon function. Upload the data so people can help you.
David du Preez
David du Preez am 20 Okt. 2019
I have attached the data here,now
BN
BN am 4 Nov. 2019
what is x and y in your data?
how to produce them?

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

jonas
jonas am 20 Okt. 2019
Bearbeitet: jonas am 20 Okt. 2019

2 Stimmen

load data.mat
% Gridded data
in = inpolygon(X,Y,lon,lat)
uvi_mean=uvi_mean';
uvi_mean(~in)=NaN;
pcolor(X,Y,uvi_mean);
shading interp
colormap jet
hold on
% used [lat lon] = borders('countries');
pgon = polyshape(lon,lat,'simplify',false);
plot(pgon,'FaceColor','none','edgecolor','k','facealpha',1)
You can get a nicer border by upsampling (interpolate) your matrix.
load data.mat
%upsample
uvi_mean=uvi_mean';
xn = min(X(:)):0.1:max(X(:));
yn = min(Y(:)):0.1:max(Y(:));
[Xn,Yn] = meshgrid(xn,yn);
VQ = interp2(X,Y,uvi_mean,Xn,Yn);
% Gridded data
in = inpolygon(Xn,Yn,lon,lat)
VQ(~in)=NaN;
pcolor(Xn,Yn,VQ);
shading interp
colormap jet
hold on
% used [lat lon] = borders('countries');
pgon = polyshape(lon,lat,'simplify',false);
plot(pgon,'FaceColor','none','edgecolor','k','facealpha',1)
untitled.jpg

Weitere Antworten (0)

Kategorien

Gefragt:

am 20 Okt. 2019

Kommentiert:

BN
am 4 Nov. 2019

Community Treasure Hunt

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

Start Hunting!

Translated by