geopandas.sindex.SpatialIndex.intersection#

SpatialIndex.intersection(coordinates)[来源]#

与 rtree.index.Index.intersection 的兼容性包装,使用 query 代替。

Parameters:
coordinatessequence or array

形如 (min_x, min_y, max_x, max_y) 的序列用于查询矩形,或 (x, y) 用于查询点。

示例

>>> from shapely.geometry import Point, box
>>> s = geopandas.GeoSeries(geopandas.points_from_xy(range(10), range(10)))
>>> s
0    POINT (0 0)
1    POINT (1 1)
2    POINT (2 2)
3    POINT (3 3)
4    POINT (4 4)
5    POINT (5 5)
6    POINT (6 6)
7    POINT (7 7)
8    POINT (8 8)
9    POINT (9 9)
dtype: geometry
>>> s.sindex.intersection(box(1, 1, 3, 3).bounds)
array([1, 2, 3])

或者,您可以使用 query:

>>> s.sindex.query(box(1, 1, 3, 3))
array([1, 2, 3])