PostgreSQL polygon(path) Function
The PostgreSQL polygon(path)
function turns a closed path into a polygon with the same number of points and returns.
polygon(path)
Syntax
This is the syntax of the PostgreSQL polygon(path)
function:
polygon(path) -> polygon
Parameters
path
-
Required. A closed path. E.g:
path '((1,1),(-1,1),(0,-1))'
Return value
The PostgreSQL polygon(path)
function returns a polygon with the same number of points converted from the closed path specified by the parameter.
PostgreSQL will give an error if you provide an open path via the parameter.
polygon(path)
Examples
The following statement shows how to use the PostgreSQL polygon(path)
function to convert a closed path path '((1,1),(-1,1),(0,-1))'
to a polygon.
SELECT polygon(path '((1,1),(-1,1),(0,-1))');
polygon
-----------------------
((1,1),(-1,1),(0,-1))
The following statement shows how to use the PostgreSQL polygon(path)
function to convert a closed path path '((2,2),(1,1),(3,0),(4,0))'
to a polygon.
SELECT polygon(path '((2,2),(1,1),(3,0),(4,0))');
polygon
---------------------------
((2,2),(1,1),(3,0),(4,0))