pygeoops.collection_extract#

pygeoops.collection_extract(geometry, primitivetype: int | PrimitiveType | Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str] | None = None) BaseGeometry | ndarray[tuple[Any, ...], dtype[BaseGeometry]] | None#

Extracts the parts from the input that comply with the type specified.

Parameters:
  • geometry (geometry, GeoSeries or arraylike) – geometry or arraylike.

  • primitivetype (Union[int, PrimitiveType] or arraylike) – the type of geometries to keep in the output. Either one or an arraylike of PrimitiveType or an int with one of the following values: 0: all, 1: points, 2: lines, 3: polygons.

Raises:

ValueError – if geometry is an unsupported geometry type or (a) primitivetype is invalid.

Returns:

geometry or array of

geometries containing only parts of the primitive type specified.

Return type:

Union[BaseGeometry, NDArray[BaseGeometry], None]