Repository navigation
[GH-2070] Geopandas.GeoSeries: Implement get_geometry - #2071
Conversation
get_geometryget_geometry
| -------- | ||
| >>> from shapely.geometry import Point, MultiPoint, GeometryCollection | ||
| >>> s = geopandas.GeoSeries( | ||
| ... [ |
There was a problem hiding this comment.
Polygon Empty isn't special, but MultiPolygon Empty is interesting, since it's a collection. Our ST_GeometryN errors when we use a negative index out of scope of the length of the Multi geometry object.
e.g
SELECT ST_GeometryN(MultiPolygon(Point(1, 1)), -2); -- errors
SELECT ST_GeometryN(MultiPolygon(), -1); -- errorsGeopandas returns null in this case. PostGIS also returns null in this case (the PostGIS implementation is already very different than ours since they use 1-indexing).
We can either fix this on the java Sedona level, Python dataframe level or just the geopandas level (case statement). Which do you think @jiayuasu ?
There was a problem hiding this comment.
Actually, I thought about it some more and decided to implement on geopandas level. I forgot the existing negative index handling logic was already implemented there.
ab1b8d9 to
b417155
Compare
zhangfengcdt
left a comment
There was a problem hiding this comment.
looks like the sheply 1 still has issue with one of the tests
|
@petern48 I am fine dropping Shapely 1.x support in the next Sedona major release. What do you think? @Kontinuation |
|
We don't necessarily have to drop support for shapely 1 in all of sedona if you don't want to. We could also just drop it for geopandas specifically, or skip this test for shapely 1 and accept the difference. Of course, updating documentation however necessary. Dropping support would make my life easier, but it's probably not necessarily at this point. Looking at the error output, it looks like shapely 1, automatically interprets expected = gpd.GeoSeries(
[
Point(0, 0),
Point(0, 0),
MultiPoint([(0, 0), (1, 1), (0, 1), (1, 0)]),
Polygon(),
None,
]
)From the logs: (idk why it's formatted this way, but GeometryCollection Empty corresponds to the Polygon() object) |
|
I personally think it's reasonable to just skip the test for shapely < 2.0.0 and update the docs about the behavior. Pushed a change. What do you think? |
…#2071) * Implement get_geometry * Skip test for old versions * Support extra-negative indices * Skip test for shapely < 2.0.0 * Update docs to mention the shapely < 2.0.0 behavior
…#2071) * Implement get_geometry * Skip test for old versions * Support extra-negative indices * Skip test for shapely < 2.0.0 * Update docs to mention the shapely < 2.0.0 behavior
Did you read the Contributor Guide?
Is this PR related to a ticket?
[GH-XXX] my subject. Closes Geopandas.GeoSeries: Implmementget_geometry#2070What changes were proposed in this PR?
Implement get_geometry
How was this patch tested?
Added tests
Did this PR include necessary documentation updates?