ST_IsClosed()

TL;DR

Use ST_IsClosed() to test whether a line’s first and last coordinates match.

Returns whether a line geometry is closed.

Syntax

ST_IsClosed(geom)

Arguments

Argument

Description

geom

A GEOMETRY or GEOMETRY32 line value.

Return Value

Returns bool.

Usage Notes

Examples

DROP DATABASE IF EXISTS geo_accessor_demo;
CREATE DATABASE geo_accessor_demo;
USE geo_accessor_demo;
SELECT ST_IsClosed(ST_GeomFromText('LINESTRING(0 0,1 0,1 1,0 0)')) AS is_closed;
DROP DATABASE geo_accessor_demo;

See Also

ST_IsRing, ST_StartPoint