All Products
Search
Document Center

MaxCompute:ST_MAKEPOLYGON

Last Updated:Aug 26, 2026

The ST_MAKEPOLYGON function constructs a polygon geography object from a specified shell and zero or more holes.

Syntax

GEOGRAPHY ST_MAKEPOLYGON(GEOGRAPHY <shell>[, ARRAY<GEOGRAPHY> <holes>])

Parameters

  • shell: Required. A linestring geography object.

  • holes: Optional. An ARRAY of linestring geography objects.

You can use the ST_MAKELINE function to construct linestring geography objects. Note the following:

  • A linestring must contain at least three distinct vertices.

  • A linestring must be closed, meaning its first and last vertex must be the same. If not, the function automatically closes the linestring by adding a segment from the last vertex to the first.

Return value

Returns a polygon geography object. The following rules apply:

  • If any input argument is NULL or the holes array contains a NULL element, the function returns NULL.

  • If any input geography object is empty, the function returns an error.

  • The S2 Geometry Library's precision limitations may cause minor differences between the input and output.

Examples

-- Create a polygon from a shell without any holes
SELECT ST_MAKEPOLYGON(ST_GEOGFROMTEXT('LINESTRING(0 0, 1 0, 1 1)'));
-- Result:
+--------------------------------+
| _c0                            |
+--------------------------------+
| POLYGON ((0 0, 1 0, 1 1, 0 0)) |
+--------------------------------+


-- Create a polygon with both a shell and a hole
SELECT ST_MAKEPOLYGON(ST_GEOGFROMTEXT('LINESTRING(0 0, 10 0, 10 10, 0 10, 0 0)'), ARRAY(ST_GEOGFROMTEXT('LINESTRING(2 2, 2 4, 4 4, 4 2, 2 2)')));
-- Result:
+--------------------------------------------------------------------+
| _c0                                                                |
+--------------------------------------------------------------------+
| POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0), (4 2, 4 4, 2 4, 2 2, 4 2)) |
+--------------------------------------------------------------------+

Related topics