PostgreSQL polygon(integer, circle) Function

The PostgreSQL polygon(integer, circle) function converts a circle to a polygon represented by a specified number of points and returns it.

polygon(integer, circle) Syntax

This is the syntax of the PostgreSQL polygon(integer, circle) function:

polygon(integer, circle) -> polygon

Parameters

integer

Required. An integer, it specifies the number of points in the polygon.

circle

Required. A circle. e.g:circle '<(0,0),2>'.

Return value

The PostgreSQL polygon(integer, circle)function returns a polygon represented by the specified number of points converted from the circle specified by the parameter.

polygon(integer, circle) Examples

The following statement shows how to use the PostgreSQL polygon(integer, circle) function to convert a circle circle '<(0,0),2>' into a 3-point polygon.

SELECT polygon(3, circle '<(0,0),2>');
                                         polygon
------------------------------------------------------------------------------------------
 ((-2,0),(0.9999999999999996,1.7320508075688774),(1.0000000000000009,-1.732050807568877))

The following statement shows how to use the PostgreSQL polygon(integer, circle) function to convert a circle circle '<(1,2),3>' into a 4-point polygon.

SELECT polygon(4, circle '<(1,2),3>');
                                    polygon
--------------------------------------------------------------------------------
 ((-2,2),(0.9999999999999998,5),(4,2.0000000000000004),(1.0000000000000004,-1))