dtoolkit.geoaccessor.geoseries.select_geom_type#
- dtoolkit.geoaccessor.geoseries.select_geom_type(s: gpd.GeoSeries, geom_type: GEOM_TYPE, /, complement: bool = False) gpd.GeoSeires [source]#
Select geometries by geometry type.
- Parameters:
- geom_type{“Point”, “MultiPoint”, “LineString”, “LinearRing”, “MultiLineString”, “Polygon”, “MultiPolygon”, “GeometryCollection”}
Geometry type.
- complementbool, default False
If True, do operation reversely.
- Returns:
- GeoSeries
Return selected geometries.
See also
Examples
>>> import dtoolkit.geoaccessor >>> import pandas as pd >>> df = pd.DataFrame({ ... "wkt": [ ... "POINT (1 1)", ... "MULTIPOINT (1 1, 2 2)", ... "LINESTRING (1 1, 2 2)", ... "LINEARRING (0 0, 0 1, 1 1, 1 0, 0 0)", ... "MULTILINESTRING ((1 1, 2 2), (3 3, 4 4))", ... "POLYGON ((0 0, 0 1, 1 1, 1 0, 0 0))", ... "MULTIPOLYGON (((0 0, 0 1, 1 1, 1 0, 0 0)))", ... "GEOMETRYCOLLECTION (POINT (1 1), LINESTRING (1 1, 2 2))", ... ], ... }).from_wkt("wkt").drop(columns="wkt") >>> df geometry 0 POINT (1.00000 1.00000) 1 MULTIPOINT ((1.00000 1.00000), (2.00000 2.00000)) 2 LINESTRING (1.00000 1.00000, 2.00000 2.00000) 3 LINEARRING (0.00000 0.00000, 0.00000 1.00000, ... 4 MULTILINESTRING ((1.00000 1.00000, 2.00000 2.0... 5 POLYGON ((0.00000 0.00000, 0.00000 1.00000, 1.... 6 MULTIPOLYGON (((0.00000 0.00000, 0.00000 1.000... 7 GEOMETRYCOLLECTION (POINT (1.00000 1.00000), L... >>> df.select_geom_type("Point") geometry 0 POINT (1.00000 1.00000)