I have just updated a table of polygons with a query which returned:
UPDATE parcel SET wkb_geometry = ST_Multi(wkb_geometry)
UPDATE 399212
Query returned successfully in 25 secs.
Now, all of the rows should contain multipolygons.
However, when I try validating geometries with ST_MakeValid
, it turns out that there are geometry collections in stead of multipolygons. How can I fix this or remove the geometry collections?
UPDATE parcel
SET wkb_geometry = ST_MakeValid(wkb_geometry)
WHERE ST_IsValid(wkb_geometry) = 'f'
ERROR: Geometry type (GeometryCollection) does not match column type (MultiPolygon)
NOTICE: Too few points in geometry component at or near point -121.78764087332523 37.700189714113364
Answer
Wrap your make valid in a ST_CollectionExtract, so:
UPDATE parcel
SET wkb_geometry = ST_Collectionextract(ST_MakeValid(wkb_geometry), 3)
WHERE NOT ST_IsValid(wkb_geometry)
No comments:
Post a Comment