This topic describes the ST_MakeValid function. This function converts an invalid input geometry object into a valid geometry object without deleting vertexes.
Syntax
geometry ST_MakeValid(geometry input);
Parameters
Parameter | Description |
---|---|
input | The geometry object that you want to specify. |
Description
- This function processes only invalid geometry objects.
- This function supports point objects, MultiPoint objects, LineString objects, MultiLineString objects, polygon objects, MultiPolygon objects, and GeometryCollection objects. The combination of the preceding objects is also supported.
- If all or partial dimensions of the input geometry object are missing, this function returns a geometry object from lower dimensions or a collection of geometry objects from lower dimensions.
- If you specify a polygon object that has self-intersections, this function may return a MULTI object.
Examples
Results returned by specifying a polygon object with self-intersections:
SELECT ST_AsText(ST_MakeValid('POLYGON((0 0,0 1,1 0,1 1,0 0))'));
st_astext
----------------------------------------------------------------
MULTIPOLYGON(((0 0,0 1,0.5 0.5,0 0)),((0.5 0.5,1 1,1 0,0.5 0.5.
.)))
(1 row)