I would like to use an ogr2ogr command to export features as multiple separate geojson files from a single GeoJSON feature collection. I have tried using the -explodecollections command but I am unsure how I use it. These are the commands I've tried...


ogr2ogr -explodecollections -f GeoJSON -t_srs crs:84 <output dir> <input geojson>


ERROR 6: The GeoJSON driver does not overwrite existing files.
ERROR 1: GeoJSON driver failed to create <output dir>


ogr2ogr -explodecollections -f GeoJSON -t_srs crs:84 <output geojson> <input geojson>


Creates a single Feature Collection containing all the features, much like the original geojson file.

I have tried loads of other combinations of these commands but with no success.

  • If anyone else is stuck on this, I managed to use Mapshaper instead, and used a command like this (the field attribute is optional. If omitted, each feature will be exported, else features are grouped by field values... 'mapshaper -i <input geojson> -split field="<fieldname>" -o format=geojson <output dir>' – B-Jizzle Apr 26 '19 at 6:47
  • It feels like you have understood wrong what -explodecollections does. It explodes collected geometries (MultiPolygons, MultiLineStrings, GeometryCollections) into simple geometries. So it deals with geometry collections, not with feature collections. – user30184 Apr 28 '19 at 17:35

Your Answer

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

Browse other questions tagged or ask your own question.