shapely.offset_curve

Contents

shapely.offset_curve#

offset_curve(geometry, distance, quad_segs=8, join_style='round', mitre_limit=5.0, **kwargs)#

Return a (Multi)LineString at a distance from the object.

For positive distance the offset will be at the left side of the input line. For a negative distance it will be at the right side. In general, this function tries to preserve the direction of the input.

Note: the behaviour regarding orientation of the resulting line depends on the GEOS version. With GEOS < 3.11, the line retains the same direction for a left offset (positive distance) or has opposite direction for a right offset (negative distance), and this behaviour was documented as such in previous Shapely versions. Starting with GEOS 3.11, the function tries to preserve the orientation of the original line.

Parameters:
geometryGeometry or array_like

Geometry or geometries for which to compute the offset.

distancefloat or array_like

Specifies the offset distance from the input geometry. Negative for right side offset, positive for left side offset.

quad_segsint, default 8

Specifies the number of linear segments in a quarter circle in the approximation of circular arcs.

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

Specifies the shape of outside corners. ‘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.

**kwargs

See NumPy ufunc docs for other keyword arguments.

Notes

Deprecated since version 2.1.0: A deprecation warning is shown if quad_segs, join_style or mitre_limit are specified as positional arguments. In a future release, these will need to be specified as keyword arguments.

Examples

>>> import shapely
>>> from shapely import LineString
>>> line = LineString([(0, 0), (0, 2)])
>>> shapely.offset_curve(line, 2)
<LINESTRING (-2 0, -2 2)>
>>> shapely.offset_curve(line, -2)
<LINESTRING (2 0, 2 2)>