shapely.within#
- within(a, b, **kwargs)#
Returns True if geometry A is completely inside geometry B.
A is within B if no points of A lie in the exterior of B and at least one point of the interior of A lies in the interior of B.
- Parameters:
- a, bGeometry or array_like
- **kwargs
See NumPy ufunc docs for other keyword arguments.
See also
Examples
>>> from shapely import LineString, Point, Polygon >>> line = LineString([(0, 0), (1, 1)]) >>> within(Point(0, 0), line) False >>> within(Point(0.5, 0.5), line) True >>> area = Polygon([(0, 0), (1, 0), (1, 1), (0, 1), (0, 0)]) >>> within(Point(0, 0), area) False >>> within(line, area) True >>> within(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)]] ... ) >>> within(Point(1, 1), polygon_with_hole) True >>> within(Point(2, 2), polygon_with_hole) False >>> within(LineString([(1, 1), (5, 5)]), polygon_with_hole) False >>> within(area, area) True >>> within(None, area) False