ST_ISVALID
functionsupportedCore SQL functionsReturns TRUE if the specified GEOGRAPHY or GEOMETRY object represents a valid shape. Examples of invalid shapes include shapes with self-intersections and spikes.
Syntax
ST_ISVALID( <geography_or_geometry_expression> )
Parameters
| Name | Required | Description |
|---|---|---|
geography_or_geometry_expression | required | The argument must be an expression of type GEOGRAPHY or GEOMETRY. |
Returns
Returns a BOOLEAN value.
Usage notes
- ST_ISVALID only checks for the validity of a shape. It doesn’t modify data. When constructing objects from spatial formats (such as WKT, WKB, EWKT, EWKB, or GeoJSON), conversion functions (for example, TO_GEOGRAPHY, TO_GEOMETRY, ST_GEOGRAPHYFROMWKT, or ST_GEOMETRYFROMWKT) parse input and by default attempt to validate or repair shapes. If a conversion function can’t repair a shape, it returns an error unless you accept invalid shapes.
- To ingest data that might be invalid (for example, data that you plan to correct later), specify TRUE for the additional allow_invalid argument when you call the conversion function to allow an invalid shape. You can then use the ST_ISVALID function to flag invalid rows in a table.
- Some geospatial functions might return an error or unusable results when given invalid shapes. Use the ST_ISVALID function to check validity. You can correct invalid shapes before performing spatial analytics.
- When shapes are invalid, simple corrections include buffering with a small positive or negative distance (for example, to remove tiny spikes or resolve self-intersections) and then rechecking validity using the ST_ISVALID function.