shapely.is_ccw

Contents

shapely.is_ccw#

is_ccw(geometry, **kwargs)#

Returns True if a linestring or linearring is counterclockwise.

Note that there are no checks on whether lines are actually closed and not self-intersecting, while this is a requirement for is_ccw. The recommended usage of this function for linestrings is is_ccw(g) & is_simple(g) and for linearrings is_ccw(g) & is_valid(g).

Parameters:
geometryGeometry or array_like

This function will return False for non-linear geometries and for lines with fewer than 4 points (including the closing point).

**kwargs

See NumPy ufunc docs for other keyword arguments.

See also

is_simple

Checks if a linestring is closed and simple.

is_valid

Checks additionally if the geometry is simple.

Examples

>>> from shapely import LinearRing, LineString, Point
>>> is_ccw(LinearRing([(0, 0), (0, 1), (1, 1), (0, 0)]))
False
>>> is_ccw(LinearRing([(0, 0), (1, 1), (0, 1), (0, 0)]))
True
>>> is_ccw(LineString([(0, 0), (1, 1), (0, 1)]))
False
>>> is_ccw(Point(0, 0))
False