PostGIS
Synopsis
boolean +`*`+ST_IsValid
*(`geometry `g`
)`;
boolean +`*`+ST_IsValid
*(`geometry `g
, integer flags`
)`;
Description
Tests if an ST_Geometry value is well-formed and valid in 2D according to the OGC rules. For geometries with 3 and 4 dimensions, the validity is still only tested in 2 dimensions. For geometries that are invalid, a PostgreSQL NOTICE is emitted providing details of why it is not valid.
For the version with the flags
parameter, supported values are
documented in ST_IsValidDetail This version
does not print a NOTICE explaining invalidity.
For more information on the definition of geometry validity, refer to Section 4.4, “Geometry Validation”
|
Performed by the GEOS module.
The version accepting flags is available starting with 2.0.0.
[.inlinemediaobject] This method implements the OGC Simple Features Implementation Specification for SQL 1.1.
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