Introduction: 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.
Format: ST_ShortestLine(geom1: Geometry, geom2: Geometry)
Return type: Geometry
Since: v1.9.0
SQL Example:
SELECT ST_ShortestLine( ST_GeomFromText('POINT (0 0)'), ST_GeomFromText('POINT (3 4)') )
Output:
LINESTRING (0 0, 3 4)
SQL Example:
SELECT ST_ShortestLine( ST_GeomFromText('POINT (0 1)'), ST_GeomFromText('LINESTRING (0 0, 1 0, 2 0, 3 0, 4 0, 5 0)') )
Output:
LINESTRING (0 1, 0 0)