You could do this using Javascript Topology Suite which will work with Node.js. Start with an empty MultiPolygon (or the first geometry in your collection) and union this with each (Multi)Polygon in your collection. You can only have one format for the whole collection, obviously, as properties are one to one with the geometry in the GeoJSON. Here are some jsts/node.js examples.
There is also a GeoJSON parser in jsts, which will return a jsts geometry. So putting it all together, you would do something along the lines of:
var jsts = require("jsts");
var reader = new jsts.io.GeoJSONParser();
//read your geometries
var geoms = reader.read(geojson);
//grab the first one
var multipolygon = geoms[0];
//union with all the others
for (var x=1; x < geoms.length ; x++){
multipolygon = multipolygon.union(geoms[x]);
}
This is untested, but the general idea should work. You would have to recreate the GeoJSON with properties afterwards, but this should be easy with the built in JSON methods in Javascript.
Your MultiPolygon is invalid. You can test it with ogrinfo:
ogrinfo -ro -dialect sqlite -sql "select IsValid(geometry) from
OGRGeoJSON" multipolygon.json
INFO: Open of `multipolygon.json'
using driver `GeoJSON' successful.
GEOS warning: Self-intersection at or near point -115.907104 39.162109000000001
Layer name: SELECT
Geometry: None
Feature Count: 1
Layer SRS WKT:
(unknown)
isvalid(geometry): Integer (0.0)
OGRFeature(SELECT):0
isvalid(geometry) (Integer) = 0
You can try to correct it in PostGIS with ST_MakeValid http://postgis.net/docs/ST_MakeValid.html. However, it is not simple
Step 1 Correct the faulty geometry:
create table valid as select st_makevalid(geometry) as geometry from multipolygon;
Step 2 Test:
select * from valid where ST_Intersects(ST_PointFromText('POINT( -116.024551 38.485773 )',4326), geometry);
Result: error
ERROR: Relate Operation called with a LWGEOMCOLLECTION type. This is unsupported.
HINT: Change argument 2: 'GEOMETRYCOLLECTION(POLYGON((-115.000793 38.677307,-115.000793 38.499878,-115....'
Pity that ST_Intersects does not handle geometrycollections. So you must get rid of the collection. First part of the collection is the polygon so you can take just that.
Step 3 Keep just the polygon part
update valid set geometry=ST_GeometryN(geometry,1);
Step 4 Test again
select * from valid where ST_Intersects(ST_PointFromText('POINT( -116.024551 38.485773 )',4326), geometry);
Result: Success!
Best Answer
As OP figured out, the ST_Dump function from PostGIS is one way to explode multipart geometries to single ones:
The following is a related post with Python alternatives: Converting huge multipolygon to polygons