Merge multiple GeoJSON files into one FeatureCollection.
$ npm install --save @mapbox/geojson-merge
Merge a series of GeoJSON objects into one FeatureCollection containing all features in all files. The objects can be any valid GeoJSON root object, including FeatureCollection, Feature, and Geometry types.
var geojsonMerge = ;var mergedGeoJSON = geojsonMerge;console;
Returns Object a geojson FeatureCollection.
Merge GeoJSON files containing GeoJSON FeatureCollections into a single stream of a FeatureCollection as a JSON string.
This is more limited than merge - it only supports FeatureCollections as input - but more performant, since it can operate on GeoJSON files larger than what you can keep in memory at one time.
var geojsonMerge = ;var mergedStream = geojsonMergemergedStream;
Returns Stream output: a stringified JSON of a FeatureCollection.
--streamto use the high-performance streaming mode. This allows you to combine very large GeoJSON files. Streaming mode requires every GeoJSON file to contain a FeatureCollection at the top level.
$ npm install -g @mapbox/geojson-merge$ geojson-merge file.geojson otherfile.geojson > combined.geojson
geojson-merge (for dummies)
- Start the
- Browse to a folder where you'd like
cmd.exetype the install string from above
- Wait patiently, it could take a moment to start
cd node_modulesto change directory to the
- For simplicity sake, move your .geojson files into this
- Run this command to merge your files:
$ node geojson-merge file1.geojson file2.geojson > merged.geojson
Merging multiple files in a folder
$ geojson-merge folder/*.geojson > combined.geojson