# simplify-path

> simplify 2D polyline

Latest version **1.1.0** (published 2015-09-11) · MIT license · 0 weekly downloads

## Install

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

## 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.0 |
| Published | 2015-09-11 |
| First published | 2014-11-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 94 |
| Author | Matt DesLauriers |
| Maintainers | mattdesl |
| Keywords | polyline, simplify, 2d, path, poly, line, douglas, radial, distance, redundant, duplicate, points |

## Links

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

## Alternatives

- [base64url](https://npm.io/package/base64url.md) — 6.1M weekly downloads
- [get-installed-path](https://npm.io/package/get-installed-path.md) — 502.9K weekly downloads
- [@uppy/url](https://npm.io/package/@uppy/url.md) — 185.8K weekly downloads
- [@d3fc/d3fc-shape](https://npm.io/package/@d3fc/d3fc-shape.md) — 16.2K weekly downloads
- [localizer](https://npm.io/package/localizer.md) — 226 weekly downloads

## Recent versions

- 1.1.0 (latest) — 2015-09-11
- 1.0.1 — 2014-11-09
- 1.0.0 — 2014-11-04

## README

# simplify-path

[![stable](http://badges.github.io/stability-badges/dist/stable.svg)](http://github.com/badges/stability-badges)

Simplifies a 2D polyline, first using a radial distance check, and then a recursive Douglas-Peucker algorithm. The code is from [simplify-js](https://github.com/mourner/simplify-js), but uses arrays for better interoperability with npm modules like stack.gl, parse-svg-path, [chaikin-smooth](https://www.npmjs.org/package/chaikin-smooth), ndarray, etc. 

```js
var simplify = require('simplify-path')

//our input polyline
var path = [ [250, 150], [250, 150], [25, 25], [24, 25], [10, 10] ]
var tolerance = 10

//result
path = simplify(path, tolerance)
```

Result: 

```
[ [ 250, 150 ], [ 25, 25 ], [ 10, 10 ] ]
```

Or you can use the algorithms individually:

```js
var path2 = simplify.radialDistance(path, tolerance)
var path3 = simplify.douglasPeucker(path, tolerance)
```

You can also require each algorithm separately:

```js
var simplify1 = require('simplify-path/radial-distance')
var simplify2 = require('simplify-path/douglas-peucker')
```

*Note:* For performance, this does not produce a deep copy of the input. 

## Usage

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

#### `simplify(path, tolerance)`

Simplifies the input path with the specified tolerance, removing redundant points first using radial distance, then Douglas-Peucker algorithm. Returns an array of simplified points.

#### `simplify.radialDistance(path, tolerance)`

Like above, but using only the Radial Distance algorithm.

#### `simplify.douglasPeucker(path, tolerance)`

Like above, but using only the Douglas-Peucker algorithm.

## License

MIT, see [LICENSE.md](http://github.com/mattdesl/simplify-path/blob/master/LICENSE.md) for details.

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