All Products
Search
Document Center

PolarDB:ST_Boundary

Last Updated:Mar 28, 2026

Returns the boundary of a geometry object.

Syntax

geometry ST_Boundary(geometry geomA);

Parameters

ParameterDescription
geomAThe input geometry object.

Description

ST_Boundary returns the boundary of the input geometry based on the geometry type:

  • Point: returns an empty GeometryCollection.

  • LineString: returns a MultiPoint containing the boundary points.

  • Polygon without interior rings: returns a closed LineString representing the exterior ring.

  • Polygon with interior rings: returns a MultiLineString containing all ring boundaries as closed LineStrings.

ST_Boundary supports 3D geometries and preserves Z coordinates.

Examples

Point

A point has no boundary, so the function returns an empty GeometryCollection.

SELECT ST_AsText(ST_Boundary('POINT(1 0)'::geometry));
        st_astext
--------------------------
 GEOMETRYCOLLECTION EMPTY
(1 row)

LineString

The boundary of a LineString is the MultiPoint formed by its two endpoints.

SELECT ST_AsText(ST_Boundary('LINESTRINGM(1 0 1, 2 0 2)'::geometry));
      st_astext
---------------------
 MULTIPOINT(1 0,2 0)
(1 row)

Polygon

The boundary of a polygon is the LineString tracing its exterior ring.

SELECT ST_AsText(ST_Boundary('POLYGON((1 0, 2 0,0 2,1 0))'::geometry));
          st_astext
-----------------------------
 LINESTRING(1 0,2 0,0 2,1 0)
(1 row)

Polygon with holes

When a polygon has interior rings, the boundary includes all ring boundaries as a MultiLineString.

SELECT ST_AsText(ST_Boundary('POLYGON((1 0,3 0,0 3,1 0),(1 0 ,2 0, 0 2 ,1 0))'::geometry));
                      st_astext
------------------------------------------------------
 MULTILINESTRING((1 0,3 0,0 3,1 0),(1 0,2 0,0 2,1 0))
(1 row)