[postgis-users] reparing invalid geometry (polygon defined by one or two points)

Ivan Mincik ivan.mincik at gmail.com
Tue Mar 24 02:02:58 PDT 2009


Dear PostGIS users,
we have quite huge MULTIPOLYGON database table containing some 3 percents of invalid geometries. 
Most problematic to repair are MULTIPOLYGONs which often contain polygon defined by one or two points.

Example is here (second polygon is defined by one point):
MULTIPOLYGON(((-266469.87 -1233431.41,-266423.25 -1233425.84,-266423.23 -1233426.17,-266422.74 -1233434.54,-266422.75 -1233439.44,-266425.68 -1233439.9,
-266457.02 -1233444.89,-266463.17 -1233437.07,-266463.27 -1233436.29,-266469.15 -1233437.08,-266469.84 -1233431.65,-266469.87 -1233431.41),(-266463.92 -1233431.02),
(-266459.41 -1233430.46,-266458.67 -1233436.67,-266451.29 -1233435.76,-266451.1 -1233437.26,-266438.9 -1233435.75,-266439.07 -1233434.35,-266426.37 -1233432.65,-266427.07 -1233426.46,
-266439.85 -1233428.04,-266459.41 -1233430.46)))

It is not possible to run buffer(0) or many other functions on these geometries because of "POSTGIS2GEOS conversion failed" (no suprise in case of such non-sense geometry).

Is there any possibility how to repair them directly in database?


Thanks
Ivan




More information about the postgis-users mailing list