ST_IsValidReason — Returns the reason why a geometry is not valid.
varchar ST_IsValidReason(bytea
Geometry);
Returns the reason why a geometry is not valid. If the Geometry is empty or Valid, it returns "Valid Geometry".
| 2D | 3D | M |
|---|---|---|
![]() | - | - |
| OGC SFS for SQL. 1.1 (1999) | OGC SFS for SQL. 1.1.0 (2005) | OGC SFS for SQL. 1.2.0 (2006)) | SQL-MM Part 3 |
|---|---|---|---|
| - | - | - | - |
SELECT ST_IsValid(geom),ST_IsValidReason(geom)
FROM (SELECT ST_GeomFromText('LINESTRING (0 0, 10 10, 20 10, 10 10)') as geom) as foo;
st_isvalid | st_isvalidreason
------------+------------------
t | Valid Geometry
(1 row)
SELECT ST_IsValid(geom),ST_IsValidReason(geom) FROM
(SELECT ST_GeomFromText('POLYGON ((0 0, 0 10, 10 10, 10 0, 0 0),(5 0, 0 5, 5 5, 5 0))') as geom) as foo;
st_isvalid | st_isvalidreason
------------+-----------------------------------------------------------
f | Interior is disconnected at or near point (0.0, 5.0, NaN)
(1 row)
SELECT ST_IsValid(geom),ST_IsValidReason(geom) FROM
(SELECT ST_GeomFromText('POLYGON ((0 0, 0 10, 10 10, 10 0, 0 0),(20 20, 20 30, 30 30, 30 20, 20 20))') as geom) as foo;
st_isvalid | st_isvalidreason
------------+------------------------------------------------------------
f | Hole lies outside shell at or near point (20.0, 20.0, NaN)
(1 row)
SELECT ST_IsValid(geom),ST_IsValidReason(geom) FROM (SELECT ST_GeomFromText('POINT EMPTY') as geom) as foo;
st_isvalid | st_isvalidreason
------------+------------------
|
(1 row)