I want to take ST_Difference or ST_Intersection to take the difference between two polygons.
SELECT a.id, a.geom, st_difference(a.geom, b.geom)
FROM liechtenstein.flaechen_norden a, liechtenstein.naturschutzgebiet b
From geometry a I want only these areas which are not in geometry b. But my code - whether ST_Difference or ST_Intersection - doesnt work, I get this error:
FEHLER: lwgeom_difference: GEOS Error: TopologyException: Input geom 0 is invalid: Ring Self-intersection at or near point 505930 5252800 at 505930 5252800
I think the problem is that there are many polgons which have a hole in themselfes. How do I include these polygons so that I get the difference?