> ## Documentation Index
> Fetch the complete documentation index at: https://docs.wherobots.com/llms.txt
> Use this file to discover all available pages before exploring further.

# ST_CollectionExtract

Returns a homogeneous multi-geometry from a given geometry collection.

The type numbers are:

1. POINT
2. LINESTRING
3. POLYGON

If the type parameter is omitted a multi-geometry of the highest dimension is returned.

<img src="https://mintcdn.com/wherobots/fqh3gPDE0J25Lra_/images/sql-functions/ST_CollectionExtract/ST_CollectionExtract.svg?fit=max&auto=format&n=fqh3gPDE0J25Lra_&q=85&s=0a3f9ed5fe0adf75815de97cbf195b3a" alt="ST_CollectionExtract" width="500" height="300" data-path="images/sql-functions/ST_CollectionExtract/ST_CollectionExtract.svg" />

## Signatures

```sql theme={"system"}
ST_CollectionExtract (A: Geometry)
```

```sql theme={"system"}
ST_CollectionExtract (A: Geometry, type: Integer)
```

## Parameters

<ParamField body="A" type="Geometry" required>
  The input geometry.
</ParamField>

<ParamField body="type" type="Integer">
  The output type.
</ParamField>

## Return type

<ResponseField type="Geometry">
  The resulting geometry.
</ResponseField>

## Example

```sql theme={"system"}
WITH test_data as (
    ST_GeomFromText(
        'GEOMETRYCOLLECTION(POINT(40 10), POLYGON((0 0, 0 5, 5 5, 5 0, 0 0)))'
    ) as geom
)
SELECT ST_CollectionExtract(geom) as c1, ST_CollectionExtract(geom, 1) as c2
FROM test_data

```

```
+----------------------------------------------------------------------------+
|c1                                        |c2                               |
+----------------------------------------------------------------------------+
|MULTIPOLYGON(((0 0, 0 5, 5 5, 5 0, 0 0))) |MULTIPOINT(40 10)                |              |
+----------------------------------------------------------------------------+
```
