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

For other keyword-only arguments, see the NumPy ufunc docs.

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