PostgreSQL polygon(box) Function

The PostgreSQL polygon(box) function converts a rectangle into a polygon represented by four points and returns.

polygon(box) Syntax

This is the syntax of the PostgreSQL polygon(box) function:

polygon(box) -> polygon

Parameters

box

Required. A rectangle, e.g:box '(1,1),(-1,-1)'.

Return value

The PostgreSQL polygon(box) function returns a polygon represented by four points converted from the rectangle specified by the parameter.

polygon(box) Examples

The following statement shows how to use the PostgreSQL polygon(box) function to convert the box box '(1,1),(-1,-1)' to a polygon.

SELECT polygon(box '(1,1),(-1,-1)');
            polygon
-------------------------------
 ((-1,-1),(-1,1),(1,1),(1,-1))

The following statement shows how to use the PostgreSQL polygon(box) function to convert the box box '(2,2),(1,1)' to a polygon.

SELECT polygon(box '(2,2),(1,1)');
          polygon
---------------------------
 ((1,1),(1,2),(2,2),(2,1))