Is it possible to import a shape file containing multipolygons into single polygon in PostGIS? Whenever I try importing a shape file of a polygon, it is stored as a multipolygon (as opposed to a single polygon) in a geom
column. Thus, I am unable to extract it as a single polygon value from the multipolygon.
All helpful suggestions much appreciated
I used ST_DUMP to convert a table of multipolygon geometries in PostgreSQL to a new table with polygon geometries and other columns of 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;
Update: I think this could be accomplished much easier with this query.
CREATE TABLE polygon_table AS
SELECT id, example_column, (ST_DUMP(geom)).geom::geometry(Polygon,4326) AS geom FROM multipolygon_table