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

Calculates and returns the length value representing the maximum distance between any two points across the input geometries. This function is an alias for `ST_LongestDistance`.

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

## Signatures

```sql theme={"system"}
ST_MaxDistance(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="Double">
  A numeric value.
</ResponseField>

## Example

```sql theme={"system"}
SELECT ST_MaxDistance(
        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))")
)
```

```
36.05551275463989
```
