dtoolkit.geoaccessor.geoseries.duplicated_geometry_groups#
- dtoolkit.geoaccessor.geoseries.duplicated_geometry_groups(s: GeoSeries, /, predicate: Literal['intersects', 'crosses', 'overlaps', 'touches', 'covered_by', 'contains_properly', 'contains', 'within', 'covers'] = 'intersects') Series [source]#
Labels of duplicate geometries.
- Parameters:
- predicate{‘intersects’, ‘crosses’, ‘overlaps’, ‘touches’, ‘covered_by’, ‘contains_properly’, ‘contains’, ‘within’, ‘covers’}, default ‘intersects’
The binary predicate is used to validate whether the geometries are duplicates or not.
- Returns:
- Series(int64)
index
is the index of inputting,values
is the labels of groups. And labels are natural numbers.
- Warns:
- UserWarning
If the index of the inputting is not unique.
See also
Examples
>>> import dtoolkit.geoaccessor >>> import geopandas as gpd >>> from shapely import Polygon >>> df = gpd.GeoDataFrame( ... geometry=[ ... Polygon([(0,0), (1,0), (1,1), (0,1)]), ... Polygon([(1,1), (2,1), (2,2), (1,2)]), ... Polygon([(2,2), (3,2), (3,3), (2,3)]), ... Polygon([(2, 0), (3, 0), (3, 1)]), ... ], ... ) >>> df geometry 0 POLYGON ((0.00000 0.00000, 1.00000 0.00000, 1.... 1 POLYGON ((1.00000 1.00000, 2.00000 1.00000, 2.... 2 POLYGON ((2.00000 2.00000, 3.00000 2.00000, 3.... 3 POLYGON ((2.00000 0.00000, 3.00000 0.00000, 3....
0 and 1 are intersecting.
1 and 2 are intersecting.
3 is alone.
So there are two groups:
(0, 1, 2)
and(3,)
.>>> df.duplicated_geometry_groups() 0 0 1 0 2 0 3 1 dtype: int64