shapely.overlaps
shapely.overlaps#
- overlaps(a, b, **kwargs)#
Returns True if A and B spatially overlap.
A and B overlap if they have some but not all points in common, have the same dimension, and the intersection of the interiors of the two geometries has the same dimension as the geometries themselves. That is, only polyons can overlap other polygons and only lines can overlap other lines.
If either A or B are None, the output is always False.
- 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 >>> poly = Polygon([(0, 0), (0, 4), (4, 4), (4, 0), (0, 0)]) >>> # A and B share all points (are spatially equal): >>> overlaps(poly, poly) False >>> # A contains B; all points of B are within A: >>> overlaps(poly, Polygon([(0, 0), (0, 2), (2, 2), (2, 0), (0, 0)])) False >>> # A partially overlaps with B: >>> overlaps(poly, Polygon([(2, 2), (2, 6), (6, 6), (6, 2), (2, 2)])) True >>> line = LineString([(2, 2), (6, 6)]) >>> # A and B are different dimensions; they cannot overlap: >>> overlaps(poly, line) False >>> overlaps(poly, Point(2, 2)) False >>> # A and B share some but not all points: >>> overlaps(line, LineString([(0, 0), (4, 4)])) True >>> # A and B intersect only at a point (lower dimension); they do not overlap >>> overlaps(line, LineString([(6, 0), (0, 6)])) False >>> overlaps(poly, None) False >>> overlaps(None, None) False