Skip to content
🌵SedonaDB (Rust) 0.3.0 is out now, featuring larger-than-memory spatial joins, and row-level CRS!

ST_MakePolygon

Introduction: Function to convert closed linestring to polygon including holes. The holes must be a MultiLinestring. If holes are provided, they should be fully contained within the shell. Holes outside the shell will produce an invalid polygon (matching PostGIS behavior). Use ST_IsValid to check the result.

ST_MakePolygon

Format: ST_MakePolygon(geom: geometry, holes: <geometry>)

Return type: Geometry

Example:

Query:

SELECT
    ST_MakePolygon(
        ST_GeomFromText('LINESTRING(0 0, 10 0, 10 10, 0 10, 0 0)'),
        ST_GeomFromText('MultiLINESTRING((2 2, 4 2, 4 4, 2 4, 2 2))')
    ) AS polygon

Result:

+--------------------------------------------------------------------+
|polygon                                                              |
+--------------------------------------------------------------------+
|POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0), (2 2, 4 2, 4 4, 2 4, 2 2))|
+--------------------------------------------------------------------+