shapely.covered_by

Contents

shapely.covered_by#

covered_by(a, b, **kwargs)#

Return True if no point in geometry A is outside geometry B.

If you need to test multiple geometries against the same geometry A, you can improve performance by preparing A in advance using prepare().

Parameters:
a, bGeometry or array_like

Geometry or geometries to check.

**kwargs

See NumPy ufunc docs for other keyword arguments.

See also

covers

covered_by(A, B) == covers(B, A).

prepare

Improve performance by preparing a (the first argument).

within

Return True if geometry A is completely inside geometry B.

Examples

>>> import shapely
>>> from shapely import LineString, Point, Polygon
>>> line = LineString([(0, 0), (1, 1)])
>>> shapely.covered_by(Point(0, 0), line)
True
>>> shapely.covered_by(Point(0.5, 0.5), line)
True
>>> area = Polygon([(0, 0), (1, 0), (1, 1), (0, 1), (0, 0)])
>>> shapely.covered_by(Point(0, 0), area)
True
>>> shapely.covered_by(line, area)
True
>>> shapely.covered_by(LineString([(0, 0), (2, 2)]), area)
False
>>> polygon_with_hole = Polygon(
...     [(0, 0), (0, 10), (10, 10), (10, 0), (0, 0)],
...     holes=[[(2, 2), (2, 4), (4, 4), (4, 2), (2, 2)]]
... )
>>> shapely.covered_by(Point(1, 1), polygon_with_hole)
True
>>> shapely.covered_by(Point(2, 2), polygon_with_hole)
True
>>> shapely.covered_by(LineString([(1, 1), (5, 5)]), polygon_with_hole)
False
>>> shapely.covered_by(area, area)
True
>>> shapely.covered_by(None, area)
False