---
title: Polygon Constructors
slug: DA_TnlDPtQG9pZYnM4rTb
description: Construct and manage polygons in OcientGeo, suitable for representing complex spatial regions.
docTags: 
createdAt: Mon Aug 01 2022 17:31:39 GMT+0000 (Coordinated Universal Time)
updatedAt: Mon Mar 30 2026 18:52:45 GMT+0000 (Coordinated Universal Time)
---

OcientGeo™ POLYGON constructors use geospatial data to create a POLYGON object.&#x20;

# ST\_FORCECCW

Creates a standardized polygon from an existing one. Ocient® defines standardized as the exterior being counterclockwise (CCW) and all holes being clockwise (CW) oriented.

**Syntax**

```sql
ST_FORCECCW(polygon)
```

| **Argument** | **Data** **Type** | **Description**                                                                                     |
| ------------ | ----------------- | --------------------------------------------------------------------------------------------------- |
| `polygon`    | `POLYGON`         | A `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))`&#x20;

# ST\_MAKEPOLYGON

Alias for [ST\_POLYGON](./#stpolygon).

# ST\_POLYGON

Creates a `POLYGON`.

## ST\_POLYGON(geo)

Creates a `POLYGON` from the specified `POINT`, `POINT` array, `LINESTRING`, or `POLYGON` geography.&#x20;

**Syntax**

```sql
ST_POLYGON(geo)
```

| **Argument** | **Data** **Type** | **Description**                                                                                   |
| ------------ | ----------------- | ------------------------------------------------------------------------------------------------- |
| `geo`        | `POLYGON`         | A `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)

Alias for ST\_MAKEPOLYGON(char).

Creates a `POLYGON` from the specified `CHAR` representing a `POLYGON` in WKT format.&#x20;

**Syntax**

```sql
ST_POLYGON(char)
```

| **Argument** | **Data** **Type**                                  | **Description**                                               |
| ------------ | -------------------------------------------------- | ------------------------------------------------------------- |
| `char`       | `CHAR` 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)

Alias for ST\_POLYGONFROMWKB(binary).

Creates a `POLYGON` from the specified `BINARY`. The `BINARY` value must represent a `POLYGON` in WKB format.&#x20;

**Syntax**

```sql
ST_POLYGON(binary)
```

| **Argument** | **Data** **Type**                                    | **Description**                                                                                                   |
| ------------ | ---------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------- |
| `binary`     | `BINARY` 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).&#x20;

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.&#x20;

**Syntax**

```sql
ST_POLYGON(outer_ring, inner_rings)
```

| **Argument**  | **Data** **Type**                                            | **Description**                                                                                                        |
| ------------- | ------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------- |
| `outer_ring`  | `POINT`, `POINT` array, or `LINESTRING`                      | A `POINT`, `POINT` array, or `LINESTRING` that represents the outer ring of the `POLYGON` object.                      |
| `inner_rings` | `ARRAY` of `POINT` arrays, or `ARRAY` of `LINESTRING` values | An `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)))));
```

*Output*: `POLYGON((1.000000 2.000000), (1.000000 2.000000))`

# ST\_POLYGONFROMWKB

Alias for [ST\_POLYGON(binary)](./#stpolygonbinary).

# ST\_POLYGONFROMEWKT

Alias for the [ST\_POLYGON](./#stpolygon) constructor.&#x20;

Creates a `POLYGON` using an EWKT-formatted `CHAR` as an input argument.&#x20;

**Syntax**

```sql
ST_POLYGONFROMEWKT(char)
```

| **Argument** | **Data** **Type** | **Description**                                                                                                                                                                                                                                                                                                                                                           |
| ------------ | ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `char`       | `CHAR`            | A string that includes an SRID value and an EWKT-formatted value that represents a `POLYGON`.<br />Separate the values in the string by a semicolon in this format: <br />`'SRID = value; polygon_value'`<br />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))');
```

*Output*: `POLYGON((1 2,1 3,1 4,1 2))`

# ST\_POLYGONFROMGEOJSON

Creates a `POLYGON` represented by the specified GeoJSON value as an input argument.&#x20;

**Syntax**

```sql
ST_POLYGONFROMGEOJSON(geojson [, geodesic ] )
```

| **Argument** | **Data** **Type** | **Description**                                                                                                                                                                                                                                                                                                                                                |
| ------------ | ----------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `geo_json`   | `STRING`          | A string of a GeoJSON. <br />Valid GeoJSON formats follow IETF®[ standards](https://datatracker.ietf.org/doc/rfc7946/), which you can generate using the [ST\_ASGEOJSON](<./Conversion Functions.md>)  function.<br />If you specify an invalid GeoJSON, the behavior of the function is undefined. The function returns NULL if any argument is a NULL value. |
| `geodesic`   | `BOOLEAN`         | Optional. <br />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.<br />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. &#x20;

```sql
SELECT ST_POLYGONFROMGEOJSON('{"type":"Polygon","coordinates":[]}',false);
```

*Output*: `POLYGON EMPTY`

In this example, the function produces a `POLYGON` value from the GeoJSON representation.&#x20;

```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)](./#stpolygonchar).

# ST\_WHOLEEARTH

Returns the database internal representation of the whole earth polygon. The [ST\_ENVELOPE](<./Spatial Operators.md>) function returns this `POLYGON` value, with the envelope set as the entire earth.&#x20;

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();
```

*Output*: `POLYGON((0.0 0.0, 0.0 0.0, 0.0 0.0, 0.0 0.0))`

# Related Links

[Geospatial Data Types](<././Data Types.md>)

[Conversion Functions](<./Conversion Functions.md>)
