PostgreSQL line() Function

The PostgreSQL line() function returns a straight line through two specified points.

line() Syntax

This is the syntax of the PostgreSQL line() function:

line(point1, point2) -> line

Parameters

point1

Required. A point. For example: point '(0,0)'.

point2

Required. A point. For example: point '(4,4)'.

Return value

The PostgreSQL line() function returns a straight line through two specified points.

line() Examples

The following statement shows how to use the PostgreSQL line() function to construct a straight line through the point (4,4) and the point (0,0).

SELECT line(point '(4,4)', point '(0,0)');
   line
----------
 {1,-1,0}