dtoolkit.geoaccessor.geoseries.select_geom_type#
- dtoolkit.geoaccessor.geoseries.select_geom_type(s: GeoSeries, geom_type: Literal['Point', 'MultiPoint', 'LineString', 'LinearRing', 'MultiLineString', 'Polygon', 'MultiPolygon', 'GeometryCollection'], /, complement: bool = False) GeoSeries[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 1) 1 MULTIPOINT ((1 1), (2 2)) 2 LINESTRING (1 1, 2 2) 3 LINEARRING (0 0, 0 1, 1 1, 1 0, 0 0) 4 MULTILINESTRING ((1 1, 2 2), (3 3, 4 4)) 5 POLYGON ((0 0, 0 1, 1 1, 1 0, 0 0)) 6 MULTIPOLYGON (((0 0, 0 1, 1 1, 1 0, 0 0))) 7 GEOMETRYCOLLECTION (POINT (1 1), LINESTRING (1... >>> df.select_geom_type("Point") geometry 0 POINT (1 1)