Skip to content

ST_Polygonize

Builds a polygonal geometry from linear components in the input geometry.

Usage

geometry ST_Polygonize(geom: geometry)

Arguments

  • geom (geometry): Input geometry

Description

Builds a polygonal geometry from linear components in the input geometry. Handles GeometryCollection and multi-geometries by extracting linear components. Typically used with collections of complete, simple linework that forms polygon boundaries.

Unlike many geometry constructors, this doesn’t require explicit closure of rings—any closed rings in the input will become polygon boundaries.

Examples

SELECT ST_Polygonize(ST_GeomFromText('MULTILINESTRING ((0 0, 0 10, 10 10), (10 10, 10 0, 0 0))'));
┌──────────────────────────────────────────────────────────────────────────────┐
│ st_polygonize(st_geomfromtext(Utf8("MULTILINESTRING ((0 0, 0 10, 10 10), (10 │
│                              10, 10 0, 0 0))")))…                            │
╞══════════════════════════════════════════════════════════════════════════════╡
│ GEOMETRYCOLLECTION(POLYGON((0 0,0 10,10 10,10 0,0 0)))                       │
└──────────────────────────────────────────────────────────────────────────────┘