> ## 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_LineSegments

This function transforms a LineString containing multiple coordinates into an array of LineStrings, each with precisely two coordinates. The `lenient` argument, true by default, prevents an exception from being raised if the input geometry is not a LineString.

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

## Signatures

```sql theme={"system"}
ST_LineSegments(geom: Geometry, lenient: Boolean)
```

```sql theme={"system"}
ST_LineSegments(geom: Geometry)
```

## Parameters

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

<ParamField body="lenient" type="Boolean">
  The lenient value.
</ParamField>

## Return type

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

## Examples

```sql theme={"system"}
SELECT ST_LineSegments(
        ST_GeomFromWKT('LINESTRING(0 0, 10 10, 20 20, 30 30, 40 40, 50 50)'),
       false
    )
```

```
[LINESTRING (0 0, 10 10), LINESTRING (10 10, 20 20), LINESTRING (20 20, 30 30), LINESTRING (30 30, 40 40), LINESTRING (40 40, 50 50)]
```

```sql theme={"system"}
SELECT ST_LineSegments(
        ST_GeomFromWKT('POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))')
    )
```

```
[]
```
