Skip to content

Geopandas.GeoSeries: Implement proper index behavior for _row_wise_operations #2049

@petern48

Description

@petern48

After we get index support (#2036), revisit the align behavior for the row-wise operations, discussed in this PR originally #2038.

Specifically we should investigate the comments copilot made. The suggested fixes weren't right, but we may be missing something.

  • Set the index properly. It seems to be a union.
geoseries = gpd.GeoSeries([Polygon([(0, 0), (1, 0), (1, 1)]), Polygon([(0, 0), (1, 0), (1, 1)]), Polygon([(0, 0), (1, 0), (1, 1)])], index=[1, 2, 3])
geoseries2 = gpd.GeoSeries([Polygon([(0, 0), (1, 0), (1, 1)]), Polygon([(0, 0), (1, 0), (1, 1)]), Polygon([(0, 0), (1, 0), (1, 1)])], index=[0, 1, 2])
res = geoseries.intersection(geoseries2, align=True)
print(res)
print(res.index)

0                              None
1    POLYGON ((0 0, 1 1, 1 0, 0 0))
2    POLYGON ((0 0, 1 1, 1 0, 0 0))
3                              None
dtype: geometry
Index([0, 1, 2, 3], dtype='int64')
  • Investigate: Is it really an outer join really correct in all cases? Or could it be something more along the lines of a union of left and right?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions