# ST_Boundary function

The ST_Boundary function takes a geometry as an input parameter and returns its boundary as a new geometry. The resulting geometry is represented in the spatial reference system of the specified geometry.

If the specified geometry is a point, multipoint, closed curve, or closed multicurve, or if it is empty, then the result is an empty geometry of type ST_Point. For curves or multicurves that are not closed, the start points and end points of the curves are returned as an ST_MultiPoint value, unless such a point is the start or end point of an even number of curves. For surfaces and multisurfaces, the curve defining the boundary of the specified geometry is returned, either as an ST_Curve or an ST_MultiCurve value. If the specified geometry is null, then null is returned.

If possible, the specific type of the returned geometry will be ST_Point, ST_LineString, or ST_Polygon. For example, the boundary of a polygon with no holes is a single linestring, represented as ST_LineString. The boundary of a polygon with one or more holes consists of multiple linestrings, represented as ST_MultiLineString.

## Syntax

## Parameter

- geometry
- A value of type ST_Geometry or one of its subtypes. The boundary of this geometry is returned.

## Return type

ST_Geometry

## Example

In the following example, the lines of results have been reformatted for readability. The spacing in your results will vary according to your online display.

```
CREATE TABLE sample_geoms (id INTEGER, geometry ST_Geometry)
INSERT INTO sample_geoms VALUES
(1, ST_Polygon('polygon((40 120, 90 120, 90 150, 40 150, 40 120))', 0))
INSERT INTO sample_geoms VALUES
(2, ST_Polygon('polygon((40 120, 90 120, 90 150, 40 150, 40 120),
(70 130, 80 130, 80 140, 70 140, 70 130))' ,0))
INSERT INTO sample_geoms VALUES
(3, ST_Geometry('linestring(60 60, 65 60, 65 70, 70 70)' ,0))
INSERT INTO sample_geoms VALUES
(4, ST_Geometry('multilinestring((60 60, 65 60, 65 70, 70 70),
(80 80, 85 80, 85 90, 90 90),
(50 50, 55 50, 55 60, 60 60))' ,0))
INSERT INTO sample_geoms VALUES
(5, ST_Geometry('point(30 30)' ,0))
SELECT id, CAST(ST_AsText(ST_Boundary(geometry)) as VARCHAR(320)) Boundary
FROM sample_geoms
Results
ID BOUNDARY
------- --------------------------------------------------------------------
1 LINESTRING (40 120, 90 120, 90 150, 40 150, 40 120)
2 MULTILINESTRING ((40 120, 90 120, 90 150, 40 150, 40 120),
(70 130, 70 140, 80 140, 80 130, 70 130))
3 MULTIPOINT (60 60, 70 70)
4 MULTIPOINT (50 50, 70 70, 80 80, 90 90)
5 POINT EMPTY
```