This topic describes the ST_IsValidDetail function. This function returns details about whether the input geometry object is in a valid format. If not, this function returns the reasons and the invalid locations.

Syntax

validDetail  ST_IsValidDetail(geometry  geom);
validDetail  ST_IsValidDetail(geometry  geom , integer  flags);

Parameters

Parameter Description
geom The geometry object you want to specify.
flags The bitfield that you want to specify. If you specify this parameter to 1, the self-intersection ring forming a hole is considered to be valid. This is the Environmental Systems Research Institute (ESRI) flag.

Description

  • This function returns a valid_detail row. If the input geometry object is in an invalid format, the row contains the valid field stating the validity of the input geometry object, the reason field stating the reason, and a field pointing out the location of the invalid object. The value of the valid field is a Boolean value, the value of the reason field is a Varchar value, and the value of the field pointing out locations is a Geometry value.
  • This function is used to replace and improve the combination of the ST_IsValid function and the ST_IsValidReason function to generate a detailed report of the invalid geometry object.

Examples

SELECT (g).valid,(g).reason,st_astext((g).location) from (select ST_IsValidDetail('POLYGON((0 0,0 1,1 0,1 1,0 0))'::geometry) as g) as t;
 valid |      reason       |   st_astext
-------+-------------------+----------------
 f     | Self-intersection | POINT(0.5 0.5)
(1 row)