Name

ST_Boundary — Returns the boundary of a geometry.

Synopsis

geometry ST_Boundary(geometry geomA);

Description

Returns the closure of the combinatorial boundary of this Geometry. The combinatorial boundary is defined as described in section 3.12.3.2 of the OGC SPEC. Because the result of this function is a closure, and hence topologically closed, the resulting boundary can be represented using representational geometry primitives as discussed in the OGC SPEC, section 3.12.2.

Performed by the GEOS module

[Note]

Prior to 2.0.0, this function throws an exception if used with GEOMETRYCOLLECTION. From 2.0.0 up it will return NULL instead (unsupported input).

This method implements the OGC Simple Features Implementation Specification for SQL 1.1. OGC SPEC s2.1.1.1

This method implements the SQL/MM specification. SQL-MM IEC 13249-3: 5.1.17

This function supports 3d and will not drop the z-index.

Enhanced: 2.1.0 support for Triangle was introduced

Changed: 3.2.0 support for TIN, does not use geos, does not linearize curves

Examples

LineString with boundary points overlaid.

Code
SELECT ST_Boundary(geom)
FROM (SELECT 'LINESTRING(100 150,50 60,70 80,160 170)'::geometry As geom) As f;
                
Output
MULTIPOINT((100 150),(160 170))
Figure
Geometry figure for visual-st-boundary-01

Polygon holes with the boundary MultiLineString overlaid.

Code
SELECT ST_Boundary(geom)
FROM (SELECT
'POLYGON (( 10 130,50 190,110 190,140 150,150 80,100 10,20 40,10 130 ),
    ( 70 40,100 50,120 80,80 110,50 90,70 40 ))'::geometry As geom) As f;
                
Output
MULTILINESTRING((10 130,50 190,110 190,140 150,150 80,100 10,20 40,10 130),
        (70 40,100 50,120 80,80 110,50 90,70 40))
Figure
Geometry figure for visual-st-boundary-02
Code
SELECT ST_Boundary('LINESTRING(1 1,0 0,-1 1)');
Output
MULTIPOINT((1 1),(-1 1))
Figure
Geometry figure for visual-st-boundary-03
Code
SELECT ST_Boundary('POLYGON((1 1,0 0,-1 1,1 1))');
Output
LINESTRING(1 1,0 0,-1 1,1 1)
Figure
Geometry figure for visual-st-boundary-04

This example uses a 3D polygon.

Code
SELECT ST_Boundary('POLYGON((1 1 1,0 0 1,-1 1 1,1 1 1))');
Output
LINESTRING(1 1 1,0 0 1,-1 1 1,1 1 1)
Figure
Geometry figure for visual-st-boundary-05

This example uses a 3D MultiLineString.

Code
SELECT ST_Boundary('MULTILINESTRING((1 1 1,0 0 0.5,-1 1 1),(1 1 0.5,0 0 0.5,-1 1 0.5,1 1 0.5) )');
Output
MULTIPOINT(1 1 1,-1 1 1)
Figure
Geometry figure for visual-st-boundary-06