11

I have a large GeoJSON file with a single very complex MultiPolygon, and I would like to turn it into an identical file with many small polygons.

How can I do this? I can use ogr2ogr or mapshaper or PostGIS, or any other command-line tool.

This is what my file looks like:

enter image description here

Andre Silva
  • 10,259
  • 12
  • 54
  • 106
Richard
  • 3,289
  • 6
  • 35
  • 66

2 Answers2

8

As OP figured out, the ST_Dump function from PostGIS is one way to explode multipart geometries to single ones:

When the input geometry is a collection or multi it will return a record for each of the collection components, ... .

ST_Dump is useful for expanding geometries. ... . For example it can be use to expand MULTIPOLYGONS into POLYGONS.

SELECT sometable.field1, 
       (ST_Dump(sometable.the_geom)).geom AS the_geom
FROM sometable;

The following is a related post with Python alternatives: Converting huge multipolygon to polygons

Andre Silva
  • 10,259
  • 12
  • 54
  • 106
4

To convert multipolygons to polygons with ST_Dump

CREATE TABLE polytable AS 
SELECT 
id, (ST_Dump(w.geometry)).geom::geometry(Polygon,25833) AS geom 
FROM 
table_multi w
Kadir Şahbaz
  • 76,800
  • 56
  • 247
  • 389
Torsten
  • 396
  • 1
  • 8