- Notifications
You must be signed in to change notification settings - Fork34
Merge multiple GeoJSON files into one FeatureCollection.
License
mapbox/geojson-merge
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Merge multipleGeoJSON files into one FeatureCollection.
$ npm install --save @mapbox/geojson-merge
Merge a series of GeoJSON objects into one FeatureCollection containing allfeatures in all files. The objects can be any valid GeoJSON root object,including FeatureCollection, Feature, and Geometry types.
Parameters
Examples
vargeojsonMerge=require('@mapbox/geojson-merge');varmergedGeoJSON=geojsonMerge.merge([{type:'Point',coordinates:[0,1]},{type:'Feature',geometry:{type:'Point',coordinates:[0,1]},properties:{}}]);console.log(JSON.stringify(mergedGeoJSON));
ReturnsObject a geojson FeatureCollection.
Merge GeoJSON files containing GeoJSON FeatureCollectionsinto a single stream of a FeatureCollection as a JSON string.
This is more limited than merge - it only supports FeatureCollectionsas input - but more performant, since it can operate on GeoJSON fileslarger than what you can keep in memory at one time.
Parameters
Examples
vargeojsonMerge=require('@mapbox/geojson-merge');varmergedStream=geojsonMerge.mergeFeatureCollectionStream(['features.geojson','otherFeatures.geojson'])mergedStream.pipe(process.stdout);
ReturnsStream output: a stringified JSON of a FeatureCollection.
Options:
-s
or--stream
to use the high-performance streaming mode. This allowsyou to combine very large GeoJSON files. Streaming mode requires everyGeoJSON file to contain a FeatureCollection at the top level.
$ npm install -g @mapbox/geojson-merge$ geojson-merge file.geojson otherfile.geojson> combined.geojson
- Start the
node.js
application - Open
cmd.exe
- Browse to a folder where you'd like
geojson-merge
installed - In
cmd.exe
type the install string from above - Wait patiently, it could take a moment to start
- Use
cd node_modules
to change directory to thenode_modules
folder - For simplicity sake, move your .geojson files into this
node_modules
directory - 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
About
Merge multiple GeoJSON files into one FeatureCollection.
Topics
Resources
License
Code of conduct
Security policy
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors10
Uh oh!
There was an error while loading.Please reload this page.