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

Returns the LineString geometry representing the maximum distance between any two points from the input geometries.

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

## Signatures

```sql theme={"system"}
ST_LongestLine(geom1: Geometry, geom2: Geometry)
```

## Parameters

<ParamField body="geom1" type="Geometry" required>
  The geom1 value.
</ParamField>

<ParamField body="geom2" type="Geometry" required>
  The geom2 value.
</ParamField>

## Return type

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

## Example

```sql theme={"system"}
SELECT ST_LongestLine(
        ST_GeomFromText("POLYGON ((30 10, 40 40, 20 40, 10 20, 30 10))"),
        ST_GeomFromText("POLYGON ((10 20, 30 30, 40 20, 30 10, 10 20))")
)
```

```
LINESTRING (40 40, 10 20)
```
