This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.


Buffer zones for latitude-longitude polygons


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


[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.


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);
ax = usamap({'MN','NY'});
geoshow(latr, lonr, 'DisplayType', 'polygon', ...
   'FaceColor', 'blue')
title('Great Lakes')

Set the buffer width and display a buffer zone outside the lakes.

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.

[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.

ax = usamap({'MN','NY'});
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'); 
title('Exterior Buffer Zone including Polygon Interior');


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

See Also

Introduced before R2006a

Was this topic helpful?