Git Product home page Git Product logo

geojson-merge's Introduction

geojson-merge

build status

Merge multiple GeoJSON files into one FeatureCollection.

install

$ npm install --save @mapbox/geojson-merge

API

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.

Parameters

  • inputs Array<Object> a list of GeoJSON objects of any type

Examples

var geojsonMerge = require('@mapbox/geojson-merge');

var mergedGeoJSON = geojsonMerge.merge([
  { type: 'Point', coordinates: [0, 1] },
  { type: 'Feature', geometry: { type: 'Point', coordinates: [0, 1] }, properties: {} }
]);

console.log(JSON.stringify(mergedGeoJSON));

Returns Object a geojson FeatureCollection.

mergeFeatureCollectionStream

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.

Parameters

  • inputs Array<string> a list of filenames of GeoJSON files

Examples

var geojsonMerge = require('@mapbox/geojson-merge');

var mergedStream = geojsonMerge.mergeFeatureCollectionStream([
  'features.geojson',
  'otherFeatures.geojson'])

mergedStream.pipe(process.stdout);

Returns Stream output: a stringified JSON of a FeatureCollection.

cli

Options:

-s or --stream to 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)

Windows Instructions:

  1. Start the node.js application
  2. Open cmd.exe
  3. Browse to a folder where you'd like geojson-merge installed
  4. In cmd.exe type the install string from above
  5. Wait patiently, it could take a moment to start
  6. Use cd node_modules to change directory to the node_modules folder
  7. For simplicity sake, move your .geojson files into this node_modules directory
  8. 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

geojson-merge's People

Contributors

andrewharvey avatar deniscarriere avatar drewbo avatar flippmoke avatar mollymerp avatar pratikyadav avatar themapsmith avatar tmcw avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.