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

![ST\_ShortestLine between two geometries](https://mintcdn.com/wherobots/XpQVzmvmMISOboEb/images/sql-functions/ST_ShortestLine/ST_ShortestLine.svg?fit=max\&auto=format\&n=XpQVzmvmMISOboEb\&q=85\&s=4ee17936242eadd247030de221d2d7fc)

## Signatures

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

## Parameters

**geom1** `Geometry` *required*

The geometry where the shortest line starts.

**geom2** `Geometry` *required*

The geometry where the shortest line ends.

## Return type

The shortest LineString connecting the two geometries.

## Example

![ST\_ShortestLine from a point to a point](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)

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

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

Point to LineString:

![ST\_ShortestLine from a point to a linestring](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)

```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)
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.