The ST_Polygon() function

The ST_Polygon() function generates an ST_Polygon from a ring (an ST_LineString that is both simple and closed).

Syntax

ST_Polygon (ln ST_LineString)

Return type

ST_Polygon

Example

The following CREATE TABLE statement creates the polygon_test table, which has a single column, p1:
CREATE TABLE polygon_test (p1 ST_polygon);
The INSERT statement converts a ring (an ST_LineString that is both closed and simple) into an ST_Polygon and inserts it into the p1 column using the ST_LineFromText() function within the ST_Polygon() function:
INSERT INTO polygon_test VALUES(
   ST_Polygon(ST_LineFromText('linestring (10.01 20.03, 20.94
21.34, 35.93 10.04, 10.01 20.03)',1000))
);