shapely.contains_xy#
- contains_xy(geom, x, y=None, **kwargs)#
Return True if the Point (x, y) is completely inside geom.
This is a special-case (and faster) variant of the
contains()function which avoids having to create a Point object if you start from x/y coordinates.Note that in the case of points, the
contains_properly()predicate is equivalent tocontains().See the docstring of
contains()for more details about the predicate.If you need to test multiple geometries against the same geometry, you can improve performance by preparing
geomin advance usingprepare().- Parameters:
- geomGeometry or array_like
Geometry or geometries to check if they contain the point.
- x, yfloat or array_like
Coordinates as separate x and y arrays, or a single array of coordinate x, y tuples.
- **kwargs
See NumPy ufunc docs for other keyword arguments.
See also
Notes
If you compare a small number of polygons or lines with many points, it can be beneficial to prepare the geometries in advance using
shapely.prepare().Examples
>>> import shapely >>> from shapely import Point, Polygon >>> area = Polygon([(0, 0), (1, 0), (1, 1), (0, 1), (0, 0)]) >>> shapely.contains(area, Point(0.5, 0.5)) True >>> shapely.contains_xy(area, 0.5, 0.5) True