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

Returns the shortest LineString between two geometries. The line starts on `geom1` and ends on `geom2`. If either geometry is empty, the function returns null.

<img src="https://mintcdn.com/wherobots/XpQVzmvmMISOboEb/images/sql-functions/ST_ShortestLine/ST_ShortestLine.svg?fit=max&auto=format&n=XpQVzmvmMISOboEb&q=85&s=4ee17936242eadd247030de221d2d7fc" alt="ST_ShortestLine between two geometries" width="500" height="300" data-path="images/sql-functions/ST_ShortestLine/ST_ShortestLine.svg" />

## Signatures

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

## Parameters

<ParamField body="geom1" type="Geometry" required>
  The geometry where the shortest line starts.
</ParamField>

<ParamField body="geom2" type="Geometry" required>
  The geometry where the shortest line ends.
</ParamField>

## Return type

<ResponseField type="Geometry">
  The shortest LineString connecting the two geometries.
</ResponseField>

## Example

<img src="https://mintcdn.com/wherobots/XpQVzmvmMISOboEb/images/sql-functions/ST_ShortestLine/ST_ShortestLine_point_point.svg?fit=max&auto=format&n=XpQVzmvmMISOboEb&q=85&s=d6d32a8e5e0191dada421862582d826a" alt="ST_ShortestLine from a point to a point" width="500" height="300" data-path="images/sql-functions/ST_ShortestLine/ST_ShortestLine_point_point.svg" />

```sql theme={"system"}
SELECT ST_ShortestLine(
        ST_GeomFromText('POINT (0 0)'),
        ST_GeomFromText('POINT (3 4)')
)
```

```
LINESTRING (0 0, 3 4)
```

Point to LineString:

<img src="https://mintcdn.com/wherobots/XpQVzmvmMISOboEb/images/sql-functions/ST_ShortestLine/ST_ShortestLine_point_linestring.svg?fit=max&auto=format&n=XpQVzmvmMISOboEb&q=85&s=dc2a28c19e9218f50467a2ef1290e0c1" alt="ST_ShortestLine from a point to a linestring" width="500" height="300" data-path="images/sql-functions/ST_ShortestLine/ST_ShortestLine_point_linestring.svg" />

```sql theme={"system"}
SELECT ST_ShortestLine(
        ST_GeomFromText('POINT (0 1)'),
        ST_GeomFromText('LINESTRING (0 0, 1 0, 2 0, 3 0, 4 0, 5 0)')
)
```

```
LINESTRING (0 1, 0 0)
```
