Jeg brugte ST_DUMP at konvertere en tabel med multipolygongeometrier i PostgreSQL til en ny tabel med polygongeometrier og andre kolonner med data.
CREATE TABLE poly AS --poly will be the new polygon table
WITH dump AS (
SELECT id, test, --columns from your multipolygon table
(ST_DUMP(geometry)).geom AS geometry
FROM multi --the name of your multipolygon table
)
SELECT id, test,
geometry::geometry(Polygon,4326) --type cast using SRID from multipolygon
FROM dump;
Opdatering: Jeg tror, at dette kunne opnås meget lettere med denne forespørgsel.
CREATE TABLE polygon_table AS
SELECT id, example_column, (ST_DUMP(geom)).geom::geometry(Polygon,4326) AS geom FROM multipolygon_table