geopandas.GeoSeries.buffer#

GeoSeries.buffer(distance, resolution=16, cap_style='round', join_style='round', mitre_limit=5.0, single_sided=False, **kwargs)[source]#

Returns a GeoSeries of geometries representing all points within a given distance of each geometric object.

Computes the buffer of a geometry for positive and negative buffer distance.

The buffer of a geometry is defined as the Minkowski sum (or difference, for negative distance) of the geometry with a circle with radius equal to the absolute value of the buffer distance.

The buffer operation always returns a polygonal result. The negative or zero-distance buffer of lines and points is always empty.

Parameters:
distancefloat, np.array, pd.Series

The radius of the buffer in the Minkowski sum (or difference). If np.array or pd.Series are used then it must have same length as the GeoSeries.

resolutionint (optional, default 16)

The resolution of the buffer around each vertex. Specifies the number of linear segments in a quarter circle in the approximation of circular arcs.

cap_style{‘round’, ‘square’, ‘flat’}, default ‘round’

Specifies the shape of buffered line endings. 'round' results in circular line endings (see resolution). Both 'square' and 'flat' result in rectangular line endings, 'flat' will end at the original vertex, while 'square' involves adding the buffer width.

join_style{‘round’, ‘mitre’, ‘bevel’}, default ‘round’

Specifies the shape of buffered line midpoints. 'round' results in rounded shapes. 'bevel' results in a beveled edge that touches the original vertex. 'mitre' results in a single vertex that is beveled depending on the mitre_limit parameter.

mitre_limitfloat, default 5.0

Crops of 'mitre'-style joins if the point is displaced from the buffered vertex by more than this limit.

single_sidedbool, default False

Only buffer at one side of the geometry.

Examples

>>> from shapely.geometry import Point, LineString, Polygon
>>> s = geopandas.GeoSeries(
...     [
...         Point(0, 0),
...         LineString([(1, -1), (1, 0), (2, 0), (2, 1)]),
...         Polygon([(3, -1), (4, 0), (3, 1)]),
...     ]
... )
>>> s
0                         POINT (0 0)
1    LINESTRING (1 -1, 1 0, 2 0, 2 1)
2    POLYGON ((3 -1, 4 0, 3 1, 3 -1))
dtype: geometry
>>> s.buffer(0.2)
0    POLYGON ((0.2 0, 0.19904 -0.0196, 0.19616 -0.0...
1    POLYGON ((0.8 0, 0.80096 0.0196, 0.80384 0.039...
2    POLYGON ((2.8 -1, 2.8 1, 2.80096 1.0196, 2.803...
dtype: geometry

Further specification as ``join_style and cap_style are shown in the following illustration:

(Source code, png, hires.png, pdf)

../../../_images/buffer.png