フィルターのクリア

White space in map grid.

4 ビュー (過去 30 日間)
IGOR RIBEIRO
IGOR RIBEIRO 2016 年 3 月 28 日
コメント済み: Chad Greene 2016 年 3 月 29 日
Hello, I'm making a map with surfm but is getting blanks within map grid. I tried to lower the grade, but white space does not come out.
Thank you for your help.

採用された回答

Kelly Kearney
Kelly Kearney 2016 年 3 月 28 日
The mapping toolbox functions clip data that intersect the map frame. With coarsely-resolved data, this can leave some undesired whitespace around the edges. With a rectangular projection such as yours, I've found the best way to get around this issue is to set your map boundaries very carefully to the exact edge of the subset of grid cells you're plotting (or just a tiny bit wider, to avoid rounding errors).
-Kelly
  2 件のコメント
IGOR RIBEIRO
IGOR RIBEIRO 2016 年 3 月 28 日
Kelly, thanks for help. But, I don't understood. but I do not understand. I increase the flatlimit and flonlimit?
h=axesm('mapprojection','miller',...
'MapLatLimit',[-3.5 -2.5],...
'MapLonLimit',[-61 -59.5],...
'frame','on','FEdgeColor',[0.1500 0.1500 0.1500],'FFaceColor','w',...
'fLatLimit',[-3.5 -2.5],...
'fLonLimit',[-61 -59.5],...
'angleunits','degrees',...
'LabelUnits','degrees','MLabelRound',-2,'PLabelRound',-2,...
'fontname','helvetica',...
'fontweight','bold',...
'origin',[0 0 0],...
'grid','on',...
'parallellabel','on',...
'meridianlabel','on',...
'aspect','normal',...
'flinewidth',1,...
'fontsize',10,...
'mlinelocation',0.5,...
'plinelocation',0.5);
tightmap
Kelly Kearney
Kelly Kearney 2016 年 3 月 28 日
Here's a longer example that shows the problem with some fake data and your map limits:
opts = {...
'mapprojection','miller',...
'frame','on','FEdgeColor',[0.1500 0.1500 0.1500],'FFaceColor','w',...
'angleunits','degrees',...
'LabelUnits','degrees','MLabelRound',-2,'PLabelRound',-2,...
'fontname','helvetica',...
'fontweight','bold',...
'origin',[0 0 0],...
'grid','on',...
'parallellabel','on',...
'meridianlabel','on',...
'aspect','normal',...
'flinewidth',1,...
'fontsize',10,...
'mlinelocation',0.5,...
'plinelocation',0.5, ...
'mlabelparallel', 'south'};
lt = linspace(-5, 0, 20);
ln = linspace(-62, -59, 20);
latlim{1} = [-3.5 -2.5];
lonlim{1} = [-61 -59.5];
pad = [-1 1] * 0.001;
latlim{2} = lt(interp1(lt, 1:length(lt), latlim{1}, 'nearest')) + pad; % closest bounds
lonlim{2} = ln(interp1(ln, 1:length(ln), lonlim{1}, 'nearest')) + pad; % closest bounds
[lt, ln] = meshgrid(lt, ln);
z = rand(size(lt));
h = struct;
h.fig = figure('color', 'w');
h.ax(1,1) = subplot(2,2,1);
h.ax(1,2) = subplot(2,2,2);
h.ax(2,1) = subplot(2,2,3);
h.ax(2,2) = subplot(2,2,4);
for ir = 1:2
for ic = 1:2
axes(h.ax(ir,ic));
axesm(opts{:}, 'maplatlim', latlim{ir}, 'maplonlim', lonlim{ir});
tightmap;
end
end
[x,y] = mfwdtran(lt, ln);
for ii = 1:2
axes(h.ax(ii,1));
surf(x,y,z);
shading flat;
axes(h.ax(ii,2));
surfm(lt, ln, z);
end
title(h.ax(1,1), 'Original map limits, plotted with surf');
title(h.ax(1,2), 'Original map limits, plotted with surfm');
title(h.ax(2,1), 'Adjusted map limits limits, plotted with surf');
title(h.ax(2,2), 'Adjusted map limits limits, plotted with surfm');
And the resulting plot:
The top row of plots uses your map limits, with the data plotted two ways:
  • Left: using surf with projected x/y coordinates
  • Right: using surfm, with lat/lon coordinates.
As you can see, the surfm version cuts off values that the surf one doesn't. Simply projecting the coordinates yourself and plotting in the way I do in the top left is one solution to the problem, and is my preferred way of dealing with this problem, but it can be cumbersome if you're plotting lots of datasets and need to pre-project them all.
Solution 2, shown in the bottom row, is to adjust your map axis limits ( 'MapLatLimit', 'MapLonLimit') values so they're just a bit wider than a set of grid cell edges. This can be a better solution if your map boundaries are more flexible, because you can keep using all the built-in mapping plot functions.

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

その他の回答 (1 件)

Chad Greene
Chad Greene 2016 年 3 月 28 日
The surfm function discards a row and column of data on the edges. Here's a brute-force solution:
% Repeat columns on each side of data:
lat = [lat(:,1) lat lat(:,end)];
lon = [lon(:,1) lon lon(:,end)];
z = [z(:,1) z z(:,end)];
% Repeat rows on top and bottom:
lat = [lat(1,:);lat;lat(end,1)];
lon = [lon(1,:);lon;lon(end,1)];
z = [z(1,:);z;z(end,1)];
surfm(lat,lon,z)
  3 件のコメント
Kelly Kearney
Kelly Kearney 2016 年 3 月 28 日
While it's true that surfm (and all surf, pcolor, etc) all drop the last row and column of data when using flat or faceted shading, I think that's unrelated to the OP's issue. The problem with mapping toolbox functions is that they often clip data that is on the edge of the map, even if it isn't on the edge of the full data grid. See my reply for more details.
Chad Greene
Chad Greene 2016 年 3 月 29 日
Interesting. I'll have to keep that in mind.

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by