| Mapping Toolbox™ | ![]() |
[latTrimmed,lonTrimmed] = maptrimp(lat,lon,latlim,lonlim)
[latTrimmed,lonTrimmed] = maptrimp(lat,lon,latlim,lonlim) trims the polygons in lat and lon to the quadrangle specified by latlim and lonlim. latlim and lonlim are two-element vectors, defining the latitude and longitude limits respectively. lat and lon must be vectors that represent valid polygons.
maptrimp conditions the longitude limits such that:
lonlim(2) always exceeds lonlim(1)
lonlim(2) never exceeds lonlim(1) by more than 360
lonlim(1) < 180 or lonlim(2) > -180
Should the quandrangle span the Greenwich meridian, then that meridian appears at longitude = 0.
Make two polygons using the scircle1 function, and display them:
[latTrimmed,lonTrimmed] = scircle1([0 0]',[-90 90]',[70 70]');
axesm('pcarree','Grid','on',...
'MeridianLabel','on','ParallelLabel','on')
h = fillm(latTrimmed,lonTrimmed,'green');

Now trim the data to lie between 80ºS and 45ºN latitude, and 120ºW and 0º longitude. The coordinates are in two-column arrays coming out of scircle1, which you must first turn into NaN-delimited vectors:
latTrimmed = [latTrimmed; NaN NaN];
lonTrimmed = [lonTrimmed; NaN NaN];
[lat,lon] = maptrimp(latTrimmed(:),lonTrimmed(:),...
[-80 45],[-120 0]);
clmo(h)
fillm(lat,lon,'green')

Notice that the patch face to the east, lying completely outside the allowed area, was removed. The western patch was trimmed to the required area.
![]() | maptriml | maptrims | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |