shapely.contains_properly
shapely.contains_properly#
- contains_properly(a, b, **kwargs)#
Returns True if geometry B is completely inside geometry A, with no common boundary points.
A contains B properly if B intersects the interior of A but not the boundary (or exterior). This means that a geometry A does not “contain properly” itself, which contrasts with the
contains
function, where common points on the boundary are allowed.Note: this function will prepare the geometries under the hood if needed. You can prepare the geometries in advance to avoid repeated preparation when calling this function multiple times.
- Parameters
- a, bGeometry or array_like
- **kwargs
For other keyword-only arguments, see the NumPy ufunc docs.
See also
Examples
>>> from shapely import Polygon >>> area1 = Polygon([(0, 0), (3, 0), (3, 3), (0, 3), (0, 0)]) >>> area2 = Polygon([(0, 0), (1, 0), (1, 1), (0, 1), (0, 0)]) >>> area3 = Polygon([(1, 1), (2, 1), (2, 2), (1, 2), (1, 1)])
area1
andarea2
have a common border:>>> contains(area1, area2) True >>> contains_properly(area1, area2) False
area3
is completely insidearea1
with no common border:>>> contains(area1, area3) True >>> contains_properly(area1, area3) True