ST_Boundary
Calculates the boundary of the specified GEOMETRY object. An object's boundary is the set of points that define the limit of the object.
For a linestring, the boundary is the start and end points. For a polygon, the boundary is a linestring that begins and ends at the same point.
Behavior Type
Syntax
ST_Boundary( g )
Arguments
g |
Spatial object for which you want the boundary, type GEOMETRY |
Returns
GEOMETRY
Supported Data Types
Data Type | GEOMETRY |
Point | Yes |
Multipoint | Yes |
Linestring | Yes |
Multilinestring | Yes |
Polygon | Yes |
Multipolygon | Yes |
GeometryCollection | No |
Examples
The following examples show how to use ST_Boundary.
Returns a linestring that represents the boundary:
=> SELECT ST_AsText(ST_Boundary(ST_GeomFromText('POLYGON((-1 -1,2 2, 0 1,-1 -1))'))); ST_AsText -------------- LINESTRING(-1 -1, 2 2, 0 1, -1 -1) (1 row)
Returns a multilinestring that contains the boundaries of both polygons:
=> SELECT ST_AsText(ST_Boundary(ST_GeomFromText('POLYGON((2 2,5 5,8 2,2 2), (4 3,5 4,6 3,4 3))'))); ST_AsText ------------------------------------------------------------------ MULTILINESTRING ((2 2, 5 5, 8 2, 2 2), (4 3, 5 4, 6 3, 4 3)) (1 row)
The boundary of a linestring is its start and end points:
=> SELECT ST_AsText(ST_Boundary(ST_GeomFromText( 'LINESTRING(1 1,2 2,3 3,4 4)'))); ST_AsText ----------------------- MULTIPOINT (1 1, 4 4) (1 row)
A closed linestring has no boundary because it has no start and end points:
=> SELECT ST_AsText(ST_Boundary(ST_GeomFromText( 'LINESTRING(1 1,2 2,3 3,4 4,1 1)'))); ST_AsText ------------------ MULTIPOINT EMPTY (1 row)