ST_MakeValid — Attempts to make an invalid geometry valid without losing vertices.
geometry ST_MakeValid(geometry input
The function attempts to create a valid representation of a given invalid geometry without losing any of the input vertices. Already-valid geometries are returned without further intervention.
Supported inputs are: LINESTRINGS, MULTILINESTRINGS, POLYGONS, MULTIPOLYGONS.
In case of full or partial dimensional collapses, the output geometry may be a collection of lower-to-equal dimension geometries or a geometry of lower dimension.
Single polygons may become multi-geometries in case of self-intersections.
Availability: 2.0.0, requires GEOS-3.3.0
Enhanced: 2.0.1, speed improvements requires GEOS-3.3.4
This function supports 3d and will not drop the z-index.