Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.ocient.com/llms.txt

Use this file to discover all available pages before exploring further.

POLYGON constructors use geospatial data to create a POLYGON object.

ST_FORCECCW

Creates a standardized polygon from an existing one. defines standardized as the exterior being counterclockwise (CCW) and all holes being clockwise (CW) oriented. Syntax
SQL
ST_FORCECCW(polygon)
ArgumentData TypeDescription
polygonPOLYGONA POLYGON to be converted on its exterior counterclockwise and clockwise for any interior holes.
Example
SQL
SELECT ST_FORCECCW(ST_POLYGON('POLYGON((0 0,0 1,1 1,1 0,0 0))'));
Output: POLYGON((0 0,1 0,1 1,0 1,0 0))

ST_MAKEPOLYGON

Alias for ST_POLYGON.

ST_POLYGON

Creates a POLYGON.

ST_POLYGON(geo)

Creates a POLYGON from the specified POINT, POINT array, LINESTRING, or POLYGON geography. Syntax
SQL
ST_POLYGON(geo)
ArgumentData TypeDescription
geoPOLYGONA POINT, POINT array, LINESTRING, or POLYGON value to be converted to a POLYGON object.
Example
SQL
SELECT ST_POLYGON(
        ST_LINESTRING(
            ST_POINT [](
                ST_POINT(1, 2),
                ST_POINT(1, 3),
                ST_POINT(1, 4),
                ST_POINT(1, 2))));
Output: POLYGON((1 2,1 3,1 4,1 2))

ST_POLYGON(char) [#st_polygon-char]

Alias for ST_MAKEPOLYGON(char). Creates a POLYGON from the specified CHAR representing a POLYGON in WKT format. Syntax
SQL
ST_POLYGON(char)
ArgumentData TypeDescription
charCHAR that represents a POLYGON in WKT format.The CHAR argument must represent a POLYGON in WKT format.
Example
SQL
SELECT ST_POLYGON('POLYGON((1 2,1 3,1 4,1 2))');
Output: POLYGON((1 2,1 3,1 4,1 2))

ST_POLYGON(binary) [#st_polygon-binary]

Alias for ST_POLYGONFROMWKB(binary). Creates a POLYGON from the specified BINARY. The BINARY value must represent a POLYGON in WKB format. Syntax
SQL
ST_POLYGON(binary)
ArgumentData TypeDescription
binaryBINARY that represents a POLYGON in WKB format.A BINARY argument to be converted to a POLYGON. The BINARY value must represent a POLYGON in WKB format.
Example
SQL
SELECT ST_POLYGON(BINARY('0x01030000000100000005000000000000000000000000000000000000000000000000000000000000000000f03f000000000000f03f000000000000f03f000000000000f03f000000000000000000000000000000000000000000000000'));
Output: POLYGON((0 0,0 1,1 1,1 0,0 0))

ST_POLYGON(outer_ring, inner_rings)

Alias for ST_MAKEPOLYGON(outerRing, innerRings). Creates a POLYGON from the specified outer ring (that must be either a POINT, POINT array, or LINESTRING) and the array of interior rings (closed lines). The interior of the POLYGON is on the left when traveling around the exterior ring. The interior of a hole is on the right when traveling around a hole. Syntax
SQL
ST_POLYGON(outer_ring, inner_rings)
ArgumentData TypeDescription
outer_ringPOINT, POINT array, or LINESTRINGA POINT, POINT array, or LINESTRING that represents the outer ring of the POLYGON object.
inner_ringsARRAY of POINT arrays, or ARRAY of LINESTRING valuesAn ARRAY of POINT arrays or LINESTRING values that represents the inner rings or holes in the POLYGON object.
Example
SQL
SELECT ST_POLYGON(
        ST_LINESTRING(ST_POINT [](ST_POINT(1, 2))),
        ST_LINESTRING [](ST_LINESTRING(ST_POINT [](ST_POINT(1, 2)))));
OutputPOLYGON((1.000000 2.000000), (1.000000 2.000000))

ST_POLYGONFROMWKB

Alias for ST_POLYGON(binary).

ST_POLYGONFROMEWKT

Alias for the ST_POLYGON constructor. Creates a POLYGON using an EWKT-formatted CHAR as an input argument. Syntax
SQL
ST_POLYGONFROMEWKT(char)
ArgumentData TypeDescription
charCHARA string that includes an SRID value and an EWKT-formatted value that represents a POLYGON.
Separate the values in the string by a semicolon in this format:
'SRID = value; polygon_value'
The input string must include the SRID = value; component. However, the database ignores this component as all Ocient geography types are SRID = 4326.
Example
SQL
SELECT ST_POLYGONFROMEWKT('SRID=4326;POLYGON((1 2,1 3,1 4,1 2))');
OutputPOLYGON((1 2,1 3,1 4,1 2))

ST_POLYGONFROMGEOJSON

Creates a POLYGON represented by the specified GeoJSON value as an input argument. Syntax
SQL
ST_POLYGONFROMGEOJSON(geojson [, geodesic ] )
ArgumentData TypeDescription
geo_jsonSTRINGA string of a GeoJSON.
Valid GeoJSON formats follow standards, which you can generate using the ST_ASGEOJSON function.
If you specify an invalid GeoJSON, the behavior of the function is undefined. The function returns NULL if any argument is a NULL value.
geodesicBOOLEANOptional.
If you specify geodesic as TRUE, the function adds points to the resulting POLYGON such that it remains within 10 meters of the original planar polygon.
If you do not specify this argument, the value defaults to FALSE.
Examples In this example, the function produces an empty POLYGON value from the GeoJSON representation.
SQL
SELECT ST_POLYGONFROMGEOJSON('{"type":"Polygon","coordinates":[]}',false);
Output: POLYGON EMPTY In this example, the function produces a POLYGON value from the GeoJSON representation.
SQL
SELECT ST_POLYGONFROMGEOJSON(
        '{"type":"Polygon","coordinates":[[[1,1],[1,5],[5,5],[5,1]]]}',
        false);
Output: POLYGON((1 1, 1 5, 5 5, 5 1))

ST_POLYGONFROMTEXT

Alias for ST_POLYGON(char).

ST_WHOLEEARTH

Returns the database internal representation of the whole earth polygon. The ST_ENVELOPE function returns this POLYGON value, with the envelope set as the entire earth. GIS specifications do not describe a canonical polygon for the whole earth, but this value serves as the Ocient-canonical polygon. The whole earth polygon is also equivalent to ST_POLYGON('POLYGON((0 0,0 0,0 0,0 0'))), which can have a separate meaning in other GIS implementations. Syntax
SQL
ST_WHOLEEARTH()
Example
SQL
SELECT ST_WHOLEEARTH();
OutputPOLYGON((0.0 0.0, 0.0 0.0, 0.0 0.0, 0.0 0.0)) Geospatial Data Types Conversion Functions
Last modified on May 21, 2026