Last active
March 1, 2020 15:51
-
-
Save mdiener21/cdd3d08cd2d939e61f3202ea59cbc61c to your computer and use it in GitHub Desktop.
Postgis remove all rings from all polygons
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UPDATE multipoly_table_with_rings AS myrings | |
SET geom = noring.geom | |
FROM ( | |
SELECT id, ST_Collect(ST_MakePolygon(geom)) AS geom | |
FROM ( | |
SELECT id, ST_NRings(geom) AS nrings, | |
ST_ExteriorRing((ST_Dump(geom)).geom) AS geom | |
FROM multipoly_table_with_rings | |
WHERE ST_NRings(geom) > 1 | |
) AS foo | |
GROUP BY gid, nrings | |
HAVING nrings > COUNT(id) | |
) AS noring | |
WHERE myrings.id = noring.id; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment