shapely.touches

Contents

shapely.touches#

touches(a, b, **kwargs)#

Return True if the only points shared between A and B are on their boundaries.

Parameters:
a, bGeometry or array_like

Geometry or geometries to check.

**kwargs

See NumPy ufunc docs for other keyword arguments.

See also

prepare

improve performance by preparing a (the first argument)

Examples

>>> from shapely import LineString, Point, Polygon
>>> line = LineString([(0, 2), (2, 0)])
>>> touches(line, Point(0, 2))
True
>>> touches(line, Point(1, 1))
False
>>> touches(line, LineString([(0, 0), (1, 1)]))
True
>>> touches(line, LineString([(0, 0), (2, 2)]))
False
>>> area = Polygon([(0, 0), (1, 0), (1, 1), (0, 1), (0, 0)])
>>> touches(area, Point(0.5, 0))
True
>>> touches(area, Point(0.5, 0.5))
False
>>> touches(area, line)
True
>>> touches(area, Polygon([(0, 1), (1, 1), (1, 2), (0, 2), (0, 1)]))
True