I have a massive Dataset from OpenStreetMap and imported it into a PostgreSQL Database using ogr2ogr. I got several warnings during this process because of multipolygons with too little vertices. Now I can’t transform the data in the Database using PostGIS, because of this invalid features. It is no Problem to losse the invalid features but I don't know how to delete them or correct them. I tried:
ALTER TABLE multipolygons ALTER COLUMN wkb_geometry TYPE geometry USING ST_Transform(ST_MakeValid(ST_SetSRID(wkb_geometry,4326)),3857);
But I got the error Message:
Polygon must have at least four points in each ring
Alter table multipolygons ADD COLUMN wkb_geom_valid geometry; Update multipolygons SET wkb_geom_valid = ST_MakeValid(wkb_geometry);
delete from multipolygons where ST_NPoints(wkb_geometry)<4 ;
select * from multipolygons where ST_isvalid(wkb_geometry)=TRUE ;
All without success.