Name

ST_IsValid — Returns true if the ST_Geometry is well formed.

Synopsis

boolean ST_IsValid(geometry g);

Description

Test if an ST_Geometry value is well formed. For geometries that are invalid, the PostgreSQL NOTICE will provide details of why it is not valid. For more information on the OGC's definition of geometry simplicity and validity, refer to "Ensuring OpenGIS compliancy of geometries"

[Note]

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

This method implements the concept of validity expressed in the OpenGIS Simple Features Implementation Specification for SQL.

This method implements the SQL/MM specification: SQL-MM 3: 5.1.9

Examples

SELECT ST_IsValid(ST_GeomFromText('LINESTRING(0 0, 1 1)')) As good_line,
	ST_IsValid(ST_GeomFromText('POLYGON((0 0, 1 1, 1 2, 1 1, 0 0))')) As bad_poly
--results
NOTICE:  Self-intersection at or near point 0 0
 good_line | bad_poly
-----------+----------
 t         | f

See Also

ST_IsSimple, ST_IsValidReason, ST_Summary