Main Content

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,bufwidth,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) where direction specifies whether the buffer zone is inside ('in') or outside ('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 value, bufferm uses 'out' as the default and returns a buffer zone outside the polygon. If you supply 'in' as the direction value, 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,bufwidth,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

collapse all

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')

Figure contains an axes object. The axes object with title Exterior Buffer Zone contains an object of type patch.

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')

Figure contains an axes object. The axes object with title Interior Buffer Zone contains an object of type patch.

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')

Use the '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');

Figure contains an axes object. The axes object with title Exterior Buffer Zone including Polygon Interior contains an object of type patch.

Tips

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

Version History

Introduced before R2006a

expand all