Hello,
I am using the presented code of this thread to mask the data points outside the border so that only data points within are displayed. Works fine so far. However, I want to use the DisplayType surface. Thus I am using geoshow to plot the data. Unfortunately it does not fill the whole map within the borders as a buffer is left.
Any ideas on this?
Here is an example:
S = shaperead('landareas', 'UseGeoCoords', true,... 'Selector',{@(name) strcmp(name,'Australia'), 'Name'});x = linspace(min(S.Lon), max(S.Lon), 100);y = linspace(min(S.Lat), max(S.Lat), 100);[x,y] = meshgrid(x,y);a = 1;b = 9;z = a + (b-a).*rand(100,100);isin = inpolygon(x,y,S.Lon,S.Lat);z2 = z;z2(~isin) = NaN;lnlim = [min(S.Lon) max(S.Lon)];ltlim = [min(S.Lat) max(S.Lat)];lt = linspace(ltlim(1), ltlim(2), 3);ln = linspace(lnlim(1), lnlim(2), 3);for ii = 1:2 ltbox{ii} = lt([1 2 2 1 1]'+(ii-1)); lnbox{ii} = ln([1 1 2 2 1]'+(ii-1));end[lnmask, ltmask] = deal(cell(2));for ii = 1:2 for jj = 1:2 [lnmask{ii,jj}, ltmask{ii,jj}] = polybool('-', ... lnbox{ii}, ltbox{jj}, S.Lon, S.Lat); endendltboxall = ltlim([1 2 2 1 1]);lnboxall = lnlim([1 1 2 2 1]);[lnmaskall, ltmaskall] = polybool('-', lnboxall, ltboxall, S.Lon, S.Lat);figure('color','w');worldmap('Australia');geoshow(y, x, z2, 'DisplayType','surface')contourcmap('jet',round(min(z2(:)),2,'significant'):1:round(max(z2(:)),... 2,'significant'),'colorbar','on','location','vertical')for ii = 1:4 patchm(ltmask{ii}, lnmask{ii}, 'w', 'edgecolor', 'none');endplotm(ltmaskall, lnmaskall, 'k');
Best Answer