Copilot commented on code in PR #2216:
URL: https://github.com/apache/sedona/pull/2216#discussion_r2249367701
##########
python/sedona/geopandas/base.py:
##########
@@ -47,41 +47,69 @@ class GeoFrame(metaclass=ABCMeta):
A base class for both GeoDataFrame and GeoSeries.
"""
- # def _reduce_for_geostat_function(
- # self,
- # sfun: Callable[["GeoSeries"], Column],
- # name: str,
- # axis: Optional[Axis] = None,
- # numeric_only: bool = True,
- # skipna: bool = True,
- # **kwargs: Any,
- # ) -> Union["GeoSeries", Scalar]:
- # raise NotImplementedError("This method is not implemented yet.")
-
@property
- @abstractmethod
def sindex(self) -> "SpatialIndex":
"""
- Returns a spatial index built from the geometries.
+ Returns a spatial index for the GeoSeries.
+
+ Note that the spatial index may not be fully
+ initialized until the first use.
+
+ Currently, sindex is not retained when calling this method from a
GeoDataFrame.
+ You can workaround this by first extracting the active geometry column
as a GeoSeries,
+ and calling this method.
Returns
-------
SpatialIndex
- The spatial index for this GeoDataFrame.
+ The spatial index.
Examples
--------
- >>> from shapely.geometry import Point
- >>> from sedona.geopandas import GeoDataFrame
+ >>> from shapely.geometry import Point, box
+ >>> from sedona.geopandas import GeoSeries
>>>
- >>> gdf = GeoDataFrame([{"geometry": Point(1, 1), "value": 1},
- ... {"geometry": Point(2, 2), "value": 2}])
- >>> index = gdf.sindex
- >>> index.size
- 2
+ >>> s = GeoSeries([Point(x, x) for x in range(5)])
+ >>> s.sindex.query(box(1, 1, 3, 3))
+ [Point(1, 1), Point(2, 2), Point(3, 3)]
+ >>> s.has_sindex
+ True
+ """
+ return _delegate_to_geometry_column("sindex", self)
+
+ @property
+ def has_sindex(self):
+ """Check the existence of the spatial index without generating it.
+
+ Use the `.sindex` attribute on a GeoDataFrame or GeoSeries
+ to generate a spatial index if it does not yet exist,
+ which may take considerable time based on the underlying index
+ implementation.
+
+ Note that the underlying spatial index may not be fully
+ initialized until the first use.
+
+ Currently, sindex is not retained when calling this method from a
GeoDataFrame.
+ You can workaround this by first extracting the active geometry column
as a GeoSeries,
+ and calling this method.
+
+ Examples
+ --------
+ >>> from shapely.geometry import Point
+ >>> s = GeoSeries([Point(x, x) for x in range(5)])
+ >>> s.has_sindex
+ False
+ >>> index = s.sindex
+ >>> gdf.has_sindex
Review Comment:
The example code references 'gdf' but the variable name should be 's' to
match the GeoSeries created in line 99.
```suggestion
>>> s.has_sindex
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]