shapely.dwithin

Contents

shapely.dwithin#

dwithin(a, b, distance, **kwargs)#

Returns True if the geometries are within a given distance.

Note

‘dwithin’ requires at least GEOS 3.10.0.

Using this function is more efficient than computing the distance and comparing the result.

Parameters:
a, bGeometry or array_like
distancefloat

Negative distances always return False.

**kwargs

See NumPy ufunc docs for other keyword arguments.

See also

distance

compute the actual distance between A and B

prepare

improve performance by preparing a (the first argument)

Examples

>>> from shapely import Point
>>> point = Point(0.5, 0.5)
>>> dwithin(point, Point(2, 0.5), 2)
True
>>> dwithin(point, Point(2, 0.5), [2, 1.5, 1]).tolist()
[True, True, False]
>>> dwithin(point, Point(0.5, 0.5), 0)
True
>>> dwithin(point, None, 100)
False