def contains(geometry, x, y): """ Vectorized (element-wise) version of `contains` which checks whether multiple points are contained by a single geometry. Parameters ---------- geometry : PreparedGeometry or subclass of BaseGeometry The geometry which is to be checked to see whether each point is contained within. The geometry will be "prepared" if it is not already a PreparedGeometry instance. x : array The x coordinates of the points to check. y : array The y coordinates of the points to check. Returns ------- Mask of points contained by the given `geometry`. """ points = _construct_points(x, y) if isinstance(geometry, PreparedGeometry): geometry = geometry.context shapely.prepare(geometry) return shapely.contains(geometry, points)
def time_contains(self): shapely.contains(self.points, self.polygon)
def test_contains_properly(): # polygon contains itself, but does not properly contains itself assert shapely.contains(polygon, polygon).item() is True assert shapely.contains_properly(polygon, polygon).item() is False
def contains(self, other): """Returns True if the geometry contains the other, else False""" return bool(shapely.contains(self, other))