1

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

  • If you want to use QGIS this is very quick using the multipart to singleparts tool. – TeddyTedTed Jan 8 at 16:23
  • Thanks! My source file is actually about 9GB(!) so I'd prefer to use something command line. – Richard Jan 8 at 16:27
  • Ah I see, I haven't done it before so I have no idea if it would work for you but you might want to have a look at this question and see if it helps at all. – TeddyTedTed Jan 8 at 16:36
  • 1
    Thanks. I ended up using PostGIS and doing CREATE TABLE polygon_table AS SELECT id (ST_Dump(geom)).geom::geometry(Polygon,27700) AS geom FROM multipolygon_table. – Richard Jan 8 at 21:20
  • @Richard would you post your findings as an answer and accept it? – Logan Byers Jan 16 at 0:43
0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.