I've imported some data in a Postgis database and some of the geometries are reported invalid (ST_IsValidReason reports self-intersection or ring self-intersection).
The queries I am performing don't seem affected by the invalid aspect of these geometries (i'm only using ST_Distance queries).
What are the things that break when geometries are invalid?
Is fixing these geometries "automatically" (buffer(geom, 0) or ST_SimplifyPreserveTopology(geom, 0.0001)) an option?
ST_Buffer(the_geom, 0.0000001)might do the trick for self intersection. Use it only if the consequences of a slightly larger geometry are not severe. – Adam Matan Aug 11 '10 at 13:07ST_Buffer(the_geom, 0.0000001)trick definitely helps a lot. – Chau Aug 11 '10 at 13:16ST_SimplifyPreserveTopology seems to be closer to what I need (valid geometry but as close as possible to the invalid original).
Any downsides in using ST_SimplifyPreserveTopology?
– diciu Aug 11 '10 at 13:26MULTIPOLYGONof two Polygons, not as a singlePOLYGON. Try to get the original WKT if possible. – Adam Matan Aug 11 '10 at 13:36ST_MakeValidcan also be useful, but examine the results to ensure it succeeded and didn't produce a geometry collection. – jpmc26 Jul 31 '15 at 23:14