SpatialIndex
Parameters
np.array of Shapely geometries, GeoSeries, or PySparkDataFrame
required
The geometries to index.
str
default:"'strtree'"
The type of spatial index to use.
str
default:"None"
The column name to extract geometry from if
geometry is a PySparkDataFrame.The query methods (
query, nearest and intersection) behave
differently depending on how the index is constructed. When constructed
from a np.array, they return indices like GeoPandas. When constructed
from a GeoSeries or PySparkDataFrame, they return geometries.is_empty
Returns
bool
True if the index is empty, False otherwise.
size
Returns
int
Number of geometries in the index.
valid_query_predicates
query predicate.
Added in version 2.0.0.
Returns
set
A new set containing
None, "intersects", and "contains".
None selects the default "intersects" behavior.intersection()
Parameters
tuple
required
Bounding box as (min_x, min_y, max_x, max_y).
Returns
list
List of geometries if constructed from a GeoSeries or PySparkDataFrame.
List of the corresponding indices if constructed from a np.array.
The result depends on how the index is constructed. When constructed
from a np.array, this method returns indices like GeoPandas. When
constructed from a GeoSeries or PySparkDataFrame, it returns geometries.Unlike GeoPandas, Sedona does not support geometry input of type
np.array or GeoSeries. Use
GeoSeries.intersects directly instead.nearest()
Parameters
BaseGeometry
required
The geometry to find the nearest neighbor for.
int
default:"1"
Number of nearest neighbors to find.
bool
default:"False"
Whether to return distances along with indices.
Returns
list or tuple
List of geometries if constructed from a GeoSeries or PySparkDataFrame.
List of the corresponding indices if constructed from a np.array.
The result depends on how the index is constructed. When constructed
from a np.array, this method returns indices like GeoPandas. When
constructed from a GeoSeries or PySparkDataFrame, it returns geometries.Unlike GeoPandas, Sedona does not support geometry input of type
np.array or GeoSeries.
query()
Parameters
BaseGeometry
required
The geometry to query against the spatial index.
str
default:"None"
Spatial predicate to filter results. Must be either ‘intersects’ (default) or ‘contains’.
bool
default:"False"
Whether to sort the results.
Returns
list
List of geometries if constructed from a GeoSeries or PySparkDataFrame.
List of the corresponding indices if constructed from a np.array.
The result depends on how the index is constructed. When constructed
from a np.array, this method returns indices like GeoPandas. When
constructed from a GeoSeries or PySparkDataFrame, it returns geometries.Unlike GeoPandas, Sedona does not support geometry input of type
np.array or GeoSeries. Use
GeoSeries.intersects directly instead.
