ST_MAKEPOLYGON()

All functions > GEOSPATIAL > ST_MAKEPOLYGON()

Creates a POLYGON from a closed LineString shell.

Signatures

Make polygon

Returns: A polygon with the given outer ring

ST_MAKEPOLYGON(shell: T) → GEOM_POLYGON or GEOG_POLYGON
sql
ParameterTypeRequiredDescription
shellTYesA closed LineString defining the outer ring

With:

  • T : Custom types: GEOM_LINESTRING | GEOG_LINESTRING

Signature notes:

  • The input LineString must be closed (first and last vertex identical); otherwise raises an error
  • No interior rings (holes); for holes use ST_GEOMFROMTEXT with a POLYGON WKT
  • Returns NULL if the input is NULL
  • On Trino: transpiled to ST_Polygon

Examples

FeatureQL
SELECT
    f1 := ST_ASTEXT(ST_MAKEPOLYGON(ST_GEOMFROMTEXT('LINESTRING (0 0, 1 0, 1 1, 0 1, 0 0)'))) -- Polygon from a closed ring
;
Result
f1 VARCHAR
POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))

Last update at: 2026/05/26 17:22:09