PostgreSQL polygon(circle) Function

The PostgreSQL polygon(circle) function converts a circle to a polygon represented by twelve points and returns.

polygon(circle) Syntax

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

polygon(circle) -> polygon

Parameters

circle

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

Return value

The PostgreSQL polygon(circle) function returns a polygon represented by twelve points converted from the circle specified by the parameter.

polygon(circle) Examples

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

SELECT polygon(circle '<(0,0),2>');
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 ((-2,0),(-1.7320508075688774,0.9999999999999999),(-1.0000000000000002,1.7320508075688772),(-1.2246467991473532e-16,2),(0.9999999999999996,1.7320508075688774),(1.732050807568877,1.0000000000000007),(2,2.4492935982947064e-16),(1.7320508075688776,-0.9999999999999994),(1.0000000000000009,-1.732050807568877),(3.6739403974420594e-16,-2),(-0.9999999999999987,-1.732050807568878),(-1.7320508075688767,-1.0000000000000009))

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

SELECT polygon(circle '<(1,2),3>');
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 ((-2,2),(-1.598076211353316,3.5),(-0.5000000000000004,4.598076211353316),(0.9999999999999998,5),(2.499999999999999,4.598076211353316),(3.5980762113533156,3.500000000000001),(4,2.0000000000000004),(3.5980762113533165,0.5000000000000009),(2.5000000000000013,-0.5980762113533156),(1.0000000000000004,-1),(-0.499999999999998,-0.5980762113533169),(-1.5980762113533151,0.49999999999999867))