Introduction: Returns text stating if the geometry is valid. If not, it provides a reason why it is invalid. The function can be invoked with just the geometry or with an additional flag. The flag alters the validity checking behavior. The flags parameter is a bitfield with the following options:
Formats:
ST_IsValidReason (A: Geometry)
ST_IsValidReason (A: Geometry, flag: Integer)
Return type: String
Since: v1.5.1
SQL Example for valid geometry:
SELECT ST_IsValidReason(ST_GeomFromWKT('POLYGON ((100 100, 100 300, 300 300, 300 100, 100 100))')) as validity_info
Output:
Valid Geometry
SQL Example for invalid geometries:
SELECT gid, ST_IsValidReason(geom) as validity_info FROM Geometry_table WHERE ST_IsValid(geom) = false ORDER BY gid
Output:
gid | validity_info -----+---------------------------------------------------- 5330 | Self-intersection at or near point (32.0, 5.0, NaN) 5340 | Self-intersection at or near point (42.0, 5.0, NaN) 5350 | Self-intersection at or near point (52.0, 5.0, NaN)