PostgreSQL box(polygon) Function

The PostgreSQL box(polygon) function returns the bounding rectangle of the specified polygon.

A rectangle box is represented by a point in the upper right corner and a point in the lower left corner, eg: (1,1),(0,0).

box(polygon) Syntax

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

box(polygon) -> box

Parameters

point

Required. one point. For example: polygon '((0,0),(1,1),(2,0))'.

Return value

The PostgreSQL box(polygon) function returns the bounding rectangle of the specified polygon.

box(polygon) Examples

The following statement shows how to use PostgreSQL box(polygon) function to return the bounding box of polygon '((0,0),(1,1),(2,0))'.

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

Here, the polygon polygon '((0,0),(1,1),(2,0))' is a triangle consisting of 3 points.

The following statement shows how to use the PostgreSQL box(polygon) function to return the bounding box of polygon '((0,0),(1,1),(2,0),(-1,1))'.

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

Here, the polygon polygon '((0,0),(1,1),(2,0),(-1,1))' is a quadrilateral consisting of 4 points.