Spatial index#
GeoPandas will use the STRtree implementation provided by the default spatial engine
(shapely.STRtree
for Shapely > 2.0, pygeos.STRtree
for Shapely < 2.0 if PyGEOS
is installed) if compatible, or rtree.index.Index
for Shapely < 2.0 when PyGEOS is
unavailable.
GeoSeries.sindex
creates a spatial index, which can use the methods and
properties documented below.
Constructor#
Generate the spatial index |
Spatial index object#
The spatial index object returned from GeoSeries.sindex
has the following
methods:
|
Compatibility wrapper for rtree.index.Index.intersection, use |
Check if the spatial index is empty |
|
|
Return the nearest geometry in the tree for each input geometry in |
|
Return the integer indices of all combinations of each input geometry and tree geometries where the bounding box of each input geometry intersects the bounding box of a tree geometry. |
Size of the spatial index |
|
Returns valid predicates for this spatial index. |
The concrete implementations currently available are
geopandas.sindex.PyGEOSSTRTreeIndex
(when using Shapely 2.0 or PyGEOS) and
geopandas.sindex.RTreeIndex
(when using Shapely <2).
In addition to the methods listed above, the rtree
-based spatial index
(geopandas.sindex.RTreeIndex
) offers the full capability of
rtree.index.Index
- see the full API in the rtree documentation.
Similarly, the PyGEOS-based spatial index
(geopandas.sindex.PyGEOSSTRTreeIndex
) offers the full capability of
pygeos.STRtree/shapely.STRtree
, including nearest-neighbor queries.
See the full API in the Shapely STRTree documentation or PyGEOS STRTree documentation.