コード例 #1
0
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)
コード例 #2
0
ファイル: benchmarks.py プロジェクト: mwtoews/shapely
 def time_contains(self):
     shapely.contains(self.points, self.polygon)
コード例 #3
0
ファイル: test_predicates.py プロジェクト: 92kns/Shapely
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
コード例 #4
0
ファイル: base.py プロジェクト: mwtoews/shapely
 def contains(self, other):
     """Returns True if the geometry contains the other, else False"""
     return bool(shapely.contains(self, other))