shapely.touches

Contents

shapely.touches#

touches(a, b, **kwargs)#

Returns True if the only points shared between A and B are on the boundary of A and B.

Parameters:
a, bGeometry or array_like
**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