Documentation Center

  • Trials
  • Product Updates

bufferm

Buffer zones for latitude-longitude polygons

Syntax

[latb,lonb] = bufferm(lat,lon,bufwidth)
[latb,lonb] = bufferm(lat,lon,bufwidth,direction)
[latb,lonb] = bufferm(lat,lon,dist,direction,npts)

Description

[latb,lonb] = bufferm(lat,lon,bufwidth) computes the buffer zone around a line or polygon. If the vectors lat and lon, in units of degrees, define a line, then latb and lonb define a polygon that contains all the points that fall within a certain distance, bufwidth, of the line. bufwidth is a scalar specified in degrees of arc along the surface. If the vectors lat and lon define a polygon, then latb and lonb define a region that contains all the points exterior to the polygon that fall within bufwidth of the polygon.

[latb,lonb] = bufferm(lat,lon,bufwidth,direction) uses the optional string direction to specify whether the buffer zone is inside 'in'or 'out' of the polygon. A third option, 'outPlusInterior', returns the union of an exterior buffer (as would be computed using 'out') with the interior of the polygon. If you do not supply a direction string, bufferm uses 'out' as the default and returns a buffer zone outside the polygon. If you supply 'in' as the direction string, bufferm returns a buffer zone inside the polygon. If you are finding the buffer zone around a line, 'out' is the only valid option.

[latb,lonb] = bufferm(lat,lon,dist,direction,npts) controls the number of points used to construct circles about the vertices of the polygon. A larger number of points produces smoother buffers, but requires more time. If npts is omitted, 13 points per circle are used.

Examples

Display buffer zones inside and outside the Great Lakes:

% Display a simplified version of the five polygons that 
% represent the Great Lakes.
load conus
tol = 0.05;
[latr, lonr] = reducem(gtlakelat, gtlakelon, tol);
figure('Color','w')
ax = usamap({'MN','NY'});
setm(ax,'MLabelLocation',5)
geoshow(latr, lonr, 'DisplayType', 'polygon', ...
   'FaceColor', 'blue')
title('Great Lakes')

% Set the buffer width and display a buffer zone outside 
% the lakes.
figure;
bufwidth = 1;  
[latb, lonb] = bufferm(latr, lonr, bufwidth);
geoshow(latb, lonb, 'DisplayType', 'polygon', ...
   'FaceColor', 'yellow')
title('Exterior Buffer Zone')

% Display a buffer zone inside the polygon.
figure;
[lati, loni] = bufferm(latr, lonr, 0.3*bufwidth, 'in');
geoshow(lati, loni, 'DisplayType', 'polygon', ...
   'FaceColor', 'magenta')
title('Interior Buffer Zone')

% Display the Great Lakes with interior and exterior
% buffer zones on a backdrop of neighboring states.
figure('Color','w')
ax = usamap({'MN','NY'});
setm(ax,'MLabelLocation',5)
geoshow(latb, lonb, 'DisplayType', 'polygon', 'FaceColor', 'yellow')
geoshow(latr, lonr, 'DisplayType', 'polygon', 'FaceColor', 'blue')
geoshow(lati, loni, 'DisplayType', 'polygon', 'FaceColor', 'magenta')
geoshow(uslat, uslon)
geoshow(statelat, statelon)
title('Great Lakes and Buffer Zones with Neighboring States')

% Example using 'outPlusInterior' option: 
bufWidth = 0.5; 
[latz, lonz] = bufferm(latr, lonr, bufWidth,'outPlusInterior'); 
figure 
geoshow(latz,lonz,'DisplayType','polygon','FaceColor','yellow') 
title('Exterior Buffer Zone including Polygon Interior');

More About

expand all

Tips

Close all polygons before processing them with bufferm. If a polygon is not closed, bufferm assumes it is a line.

See Also

Was this topic helpful?