Name

ST_IsClosed — Tests if a LineStrings's start and end points are coincident. For a PolyhedralSurface tests if it is closed (volumetric).

Synopsis

boolean ST_IsClosed(geometry g);

Description

Returns TRUE if the LINESTRING's start and end points are coincident. For Polyhedral Surfaces, reports if the surface is areal (open) or volumetric (closed).

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

This method implements the SQL/MM specification. SQL-MM 3: 7.1.5, 9.3.3

[Note]

SQL-MM defines the result of ST_IsClosed(NULL) to be 0, while PostGIS returns NULL.

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

This method supports Circular Strings and Curves.

Enhanced: 2.0.0 support for Polyhedral surfaces was introduced.

This function supports Polyhedral surfaces.

Line String and Point Examples

Code
SELECT ST_IsClosed('LINESTRING(0 0,1 1)'::geometry);
Output
f
Figure
Geometry figure for visual-st-isclosed-01
Code
SELECT ST_IsClosed('LINESTRING(0 0,0 1,1 1,0 0)'::geometry);
Output
t
Figure
Geometry figure for visual-st-isclosed-02
Code
SELECT ST_IsClosed('MULTILINESTRING((0 0,0 1,1 1,0 0),(0 0,1 1))'::geometry);
Output
f
Figure
Geometry figure for visual-st-isclosed-03
Code
SELECT ST_IsClosed('POINT(0 0)'::geometry);
Output
t
Code
SELECT ST_IsClosed('MULTIPOINT((0 0),(1 1))'::geometry);
Output
t

Polyhedral Surface Examples

This example uses a cube.

Code
SELECT ST_IsClosed('POLYHEDRALSURFACE( ((0 0 0,0 0 1,0 1 1,0 1 0,0 0 0)),
((0 0 0,0 1 0,1 1 0,1 0 0,0 0 0)),((0 0 0,1 0 0,1 0 1,0 0 1,0 0 0)),
((1 1 0,1 1 1,1 0 1,1 0 0,1 1 0)),
((0 1 0,0 1 1,1 1 1,1 1 0,0 1 0)),((0 0 1,1 0 1,1 1 1,0 1 1,0 0 1)) )');
Output
t
Figure
Geometry figure for visual-st-isclosed-06

This example uses the same cube with one side missing.

Code
SELECT ST_IsClosed('POLYHEDRALSURFACE( ((0 0 0,0 0 1,0 1 1,0 1 0,0 0 0)),
       ((0 0 0,0 1 0,1 1 0,1 0 0,0 0 0)),((0 0 0,1 0 0,1 0 1,0 0 1,0 0 0)),
       ((1 1 0,1 1 1,1 0 1,1 0 0,1 1 0)),
       ((0 1 0,0 1 1,1 1 1,1 1 0,0 1 0)) )');
Output
f
Figure
Geometry figure for visual-st-isclosed-07

See Also

ST_IsRing