# simplify-geojson

> Apply Ramer-Douglas-Peucker line simplification to GeoJSON features or feature collections in JS or on the CLI

Latest version **1.0.5** (published 2022-04-12) · BSD-2-Clause license · 0 weekly downloads

## Install

```sh
npm install simplify-geojson
pnpm add simplify-geojson
yarn add simplify-geojson
bun add simplify-geojson
```

Provides the command `simplify-geojson`.

## 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.0.5 |
| Published | 2022-04-12 |
| First published | 2014-02-20 |
| Weekly downloads | 0 |
| License | BSD-2-Clause |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 7.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 183 |
| Author | max ogden |
| Maintainers | maxogden, ungoldman |
| Keywords | Ramer-Douglas-Peucker, feature, featurecollection, geojson, line, linestring, multilinestring, multipolygon, polygon, simplification, simplify |

## Links

- npm: https://www.npmjs.com/package/simplify-geojson
- Repository: https://github.com/maxogden/simplify-geojson
- Issues: https://github.com/maxogden/simplify-geojson/issues
- npm.io page: https://npm.io/package/simplify-geojson

## Dependencies (3)

- [minimist](https://npm.io/package/minimist.md) 1.2.6
- [concat-stream](https://npm.io/package/concat-stream.md) ~1.4.1
- [simplify-geometry](https://npm.io/package/simplify-geometry.md) 0.0.2

## 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.0.5 (latest) — 2022-04-12
- 1.0.4 — 2020-09-10
- 1.0.3 — 2016-10-09
- 1.0.2 — 2016-02-19
- 1.0.1 — 2016-02-08
- 1.0.0 — 2016-02-08
- 0.0.2 — 2014-02-21
- 0.0.1 — 2014-02-20

## README

# simplify-geojson

Apply [Ramer–Douglas–Peucker](https://en.wikipedia.org/wiki/Ramer%E2%80%93Douglas%E2%80%93Peucker_algorithm) line simplification to [GeoJSON](http://www.geojson.org/) features or feature collections in JS or on the CLI.

[![NPM](https://nodei.co/npm/simplify-geojson.png)](https://nodei.co/npm/simplify-geojson/)

This module uses https://github.com/seabre/simplify-geometry for the simplification and wraps it in a interface for easily simplifying GeoJSON.

## Install

```
npm install simplify-geojson
```

## Usage

### CLI

```sh
cat data.geojson | simplify-geojson -t 0.01
```

Tolerance is specified by either `-t` or `--tolerance` and is a number in degrees (e.g. lat/lon distance). 1 degree is roughly equivalent to 69 miles. the default is 0.001, which is around a city block long.

### JS

```js
var simplify = require('simplify-geojson')
var simplified = simplify(geojson, tolerance)
```

`geojson` can be any of the following:

- Feature with a LineString
- Feature with a MultiLineString
- Feature with a Polygon
- Feature with a MultiPolygon
- FeatureCollection with any of the above

All segments in any of the supported types will be simplified (including holes in polygons, for instance).

## Examples

Convert a CSV with lat/lon columns into geojson, then simplify that geojson, then open it in [geojson.io](http://geojson.io/) (CSV is from my GPS logger and was my bike commute this morning):

```sh
npm install simplify-geojson geojsonio-cli csv2geojson -g
curl https://raw.github.com/maxogden/simplify-geojson/master/test-data/oakland-route.csv | \
  csv2geojson --lat "LATITUDE N/S" --lon "LONGITUDE E/W" --line true | \
  simplify-geojson -t 0.001 | \
  geojsonio
```

Simplify alaska's border outline and count the number of lines of the simplified geojson output (tweak `-t` to see how it affects length):

```sh
curl https://rawgit.com/johan/world.geo.json/master/countries/USA/AK.geo.json | \
  simplify-geojson -t 0.01 | \
  wc -l
```

## Contributing

Contributors welcome! Please read the [contributing guidelines](contributing.md) before getting started.

## License

[BSD-2-Clause](https://spdx.org/licenses/BSD-2-Clause.html)

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