# @mapbox/geojson-merge

> merge multiple geojson files

Latest version **1.1.1** (published 2019-11-08) · ISC license · 0 weekly downloads

## Install

```sh
npm install @mapbox/geojson-merge
pnpm add @mapbox/geojson-merge
yarn add @mapbox/geojson-merge
bun add @mapbox/geojson-merge
```

Provides the command `geojson-merge`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.1 |
| Published | 2019-11-08 |
| First published | 2016-12-22 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Unpacked size | 9.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 244 |
| Author | Tom MacWright |
| Maintainers | mapbox-admin, mapbox-machine-user, mapbox-npm, mapbox-npm-01, mapbox-npm-02, mapbox-npm-03, mapbox-npm-04, mapbox-npm-05, mapbox-npm-06, mapbox-npm-07, mapbox-npm-08, mapbox-npm-09, mapbox-npm-advanced-actions, mapbox-npm-ci |
| Keywords | geojson, merge, featurecollection |

## Links

- npm: https://www.npmjs.com/package/@mapbox/geojson-merge
- Repository: https://github.com/mapbox/geojson-merge
- Issues: https://github.com/mapbox/geojson-merge/issues
- npm.io page: https://npm.io/package/@mapbox/geojson-merge

## Dependencies (6)

- [tape](https://npm.io/package/tape.md) ^4.9.0
- [minimist](https://npm.io/package/minimist.md) ^1.2.0
- [stream-concat](https://npm.io/package/stream-concat.md) 0.1.0
- [geojson-stream](https://npm.io/package/geojson-stream.md) 0.0.1
- [geojson-fixtures](https://npm.io/package/geojson-fixtures.md) ~0.1.0
- [@mapbox/geojson-normalize](https://npm.io/package/@mapbox/geojson-normalize.md) ^0.0.1

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.1.1 (latest) — 2019-11-08
- 1.1.0 — 2019-11-08
- 1.0.2 — 2017-02-20
- 1.0.1 — 2017-01-25
- 1.0.0 — 2017-01-12
- 0.3.0 — 2016-12-22

## README

# geojson-merge

[![build status](https://secure.travis-ci.org/mapbox/geojson-merge.png)](http://travis-ci.org/mapbox/geojson-merge)

Merge multiple [GeoJSON](http://geojson.org/) files into one FeatureCollection.

## install

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

## API

<!-- Generated by documentation.js. Update this documentation by updating the source code. -->

### 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](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)>** a list of GeoJSON objects of any type

**Examples**

```javascript
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](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/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](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>** a list of filenames of GeoJSON files

**Examples**

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

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

mergedStream.pipe(process.stdout);
```

Returns **[Stream](https://nodejs.org/api/stream.html)** 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.

```bash
$ 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:  

```bash
$ node geojson-merge file1.geojson file2.geojson > merged.geojson
```

**Merging multiple files in a folder**

```bash
$ geojson-merge folder/*.geojson > combined.geojson
```

---
_Source: https://npm.io/package/@mapbox/geojson-merge · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
