PHPackages                             emcconville/point-reduction-algorithms - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. emcconville/point-reduction-algorithms

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

emcconville/point-reduction-algorithms
======================================

A collection of algorithms for reducing the number of points in polyline

v1.2.0(9y ago)61204.2k↓56.7%71GNUPHPPHP &gt;=5.4

Since Jan 9Pushed 9y ago8 watchersCompare

[ Source](https://github.com/emcconville/point-reduction-algorithms)[ Packagist](https://packagist.org/packages/emcconville/point-reduction-algorithms)[ RSS](/packages/emcconville-point-reduction-algorithms/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (2)Dependencies (3)Versions (5)Used By (1)

\#Point Reduction Algorithms

[![Latest Stable Version](https://camo.githubusercontent.com/b9ef5147de3598962ae6dbdd35dd70fb95bfc9709ebeca3a220a189caf98d6da/68747470733a2f2f706f7365722e707567782e6f72672f656d63636f6e76696c6c652f706f696e742d726564756374696f6e2d616c676f726974686d732f762f737461626c652e737667)](https://packagist.org/packages/emcconville/point-reduction-algorithms)[![Build Status](https://camo.githubusercontent.com/f436a03232d494a31458f1dc49c50b1fc18865f55997b208b51a3001ae35d1b4/68747470733a2f2f7472617669732d63692e6f72672f656d63636f6e76696c6c652f706f696e742d726564756374696f6e2d616c676f726974686d732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/emcconville/point-reduction-algorithms)[![Coverage Status](https://camo.githubusercontent.com/fd8e5c25076849f631e00466c0d269cc571cc9d138f3f57de6550774f5dc364d/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f656d63636f6e76696c6c652f706f696e742d726564756374696f6e2d616c676f726974686d732f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/emcconville/point-reduction-algorithms?branch=master)[![License](https://camo.githubusercontent.com/a6e5d9cc6cca28e4fe9998892dca4b717cc664a7acae5443f07a40f1e11b3aa4/68747470733a2f2f706f7365722e707567782e6f72672f656d63636f6e76696c6c652f706f696e742d726564756374696f6e2d616c676f726974686d732f6c6963656e73652e737667)](https://packagist.org/packages/emcconville/point-reduction-algorithms)

A collection of algorithms for reducing the number of points in polygon / polyline.

Custom shapes, polygon &amp; polyline in web-map applications, can have **too many**points. Often a shape will be rendered at a distant zoom-level, and wouldn't require such high-resolution. This library's goal is to provided basic methods to simplify &amp; reduce shapes.

Install
-------

[](#install)

With [composer](https://github.com/composer/composer).

```
$ curl -sS https://getcomposer.org/installer | php
$ cat > composer.json myOwnX, $this->myOwnY);
    }
}
```

### Ramer–Douglas–Peucker

[](#ramerdouglaspeucker)

```
use PointReduction\Common\Point,
    PointReduction\Algorithms\RamerDouglasPeucker;
$givenPoints = array(
    new Point(-84.158640, -39.822480),
    new Point(-84.159250, -39.820120),
    // ... and so one
);
$epsilon = 0.001
$reducer = new RamerDouglasPeucker($givenPoints);
$reducedPoints = $reducer->reduce($epsilon);
```

The original polygon of 2151 points has been reduced to 343.

[![Ramer–Douglas–Peucker example](https://camo.githubusercontent.com/9df8d36d144448892a36dcb7bc5d40228465f26359bcff50f6272b4778eccc12/687474703a2f2f656d63636f6e76696c6c652e636f6d2f706f696e742d726564756374696f6e2d616c676f726974686d732f6578616d706c65732f646179746f6e5f52616d6572446f75676c6173506575636b65722e737667)](https://camo.githubusercontent.com/9df8d36d144448892a36dcb7bc5d40228465f26359bcff50f6272b4778eccc12/687474703a2f2f656d63636f6e76696c6c652e636f6d2f706f696e742d726564756374696f6e2d616c676f726974686d732f6578616d706c65732f646179746f6e5f52616d6572446f75676c6173506575636b65722e737667)

### Visvalingam–Whyatt

[](#visvalingamwhyatt)

```
use PointReduction\Common\Point,
    PointReduction\Algorithms\VisvalingamWhyatt;
$givenPoints = array(
    new Point(-84.158640, -39.822480),
    new Point(-84.159250, -39.820120),
    // ... and so one
);
$desiredPointCount = 343;
$reducer = new VisvalingamWhyatt($givenPoints);
$reducedPoints = $reducer->reduce($desiredPointCount);
```

The original polygon of 2151 points has been reduced to 343.

[![Visvalingam–Whyatt example](https://camo.githubusercontent.com/68141198b83bf0652645562ccf5ead60a19c5d84e9712d13a39f266c8b6a91ce/687474703a2f2f656d63636f6e76696c6c652e636f6d2f706f696e742d726564756374696f6e2d616c676f726974686d732f6578616d706c65732f646179746f6e5f56697376616c696e67616d5768796174742e737667)](https://camo.githubusercontent.com/68141198b83bf0652645562ccf5ead60a19c5d84e9712d13a39f266c8b6a91ce/687474703a2f2f656d63636f6e76696c6c652e636f6d2f706f696e742d726564756374696f6e2d616c676f726974686d732f6578616d706c65732f646179746f6e5f56697376616c696e67616d5768796174742e737667)

### Reumann–Witkam

[](#reumannwitkam)

```
use PointReduction\Common\Point,
    PointReduction\Algorithms\ReumannWitkam;
$givenPoints = array(
    new Point(-84.158640, -39.822480),
    new Point(-84.159250, -39.820120),
    // ... and so one
);
$threshold = 0.001;
$reducer = new ReumannWitkam($givenPoints);
$reducedPoints = $reducer->reduce($threshold);
```

The original polygon of 2151 points has been reduced to 872.

[![Reumann–Witkam example](https://camo.githubusercontent.com/a62a469d5c9646be6f754967d1669bcbcf3c61e30fff615db8887bffd88ffe5e/687474703a2f2f656d63636f6e76696c6c652e636f6d2f706f696e742d726564756374696f6e2d616c676f726974686d732f6578616d706c65732f646179746f6e5f5265756d616e6e5769746b616d2e737667)](https://camo.githubusercontent.com/a62a469d5c9646be6f754967d1669bcbcf3c61e30fff615db8887bffd88ffe5e/687474703a2f2f656d63636f6e76696c6c652e636f6d2f706f696e742d726564756374696f6e2d616c676f726974686d732f6578616d706c65732f646179746f6e5f5265756d616e6e5769746b616d2e737667)

### Opheim

[](#opheim)

```
use PointReduction\Common\Point,
    PointReduction\Algorithms\Opheim;
$givenPoints = array(
    new Point(-84.158640, -39.822480),
    new Point(-84.159250, -39.820120),
    // ... and so one
);
$perpendicularTolerance = 0.005;
$radialTolerance = 0.01;
$reducer = new Opheim($givenPoints);
$reducedPoints = $reducer->reduce($perpendicularTolerance, $radialTolerance);
```

The original polygon of 2151 points has been reduced to 684.

[![Opheim example](https://camo.githubusercontent.com/0014ba73565d1aca156e2768f03b8b43cc867a1a99815213c55e7204141dcd04/687474703a2f2f656d63636f6e76696c6c652e636f6d2f706f696e742d726564756374696f6e2d616c676f726974686d732f6578616d706c65732f646179746f6e5f4f706865696d2e737667)](https://camo.githubusercontent.com/0014ba73565d1aca156e2768f03b8b43cc867a1a99815213c55e7204141dcd04/687474703a2f2f656d63636f6e76696c6c652e636f6d2f706f696e742d726564756374696f6e2d616c676f726974686d732f6578616d706c65732f646179746f6e5f4f706865696d2e737667)

### Lang

[](#lang)

```
use PointReduction\Common\Point,
    PointReduction\Algorithms\Lang;
$givenPoints = array(
    new Point(-84.158640, -39.822480),
    new Point(-84.159250, -39.820120),
    // ... and so one
);
$threshold = 0.001;
$lookAhead = 7;
$reducer = new Lang($givenPoints);
$reducedPoints = $reducer->reduce($threshold, $lookAhead);
```

The original polygon of 2151 points has been reduced to 293.

[![Lang example](https://camo.githubusercontent.com/4fda44a24e8b4d972f5dc7951951d75090d1db3363b4589f9d4b10cfac3f0591/687474703a2f2f656d63636f6e76696c6c652e636f6d2f706f696e742d726564756374696f6e2d616c676f726974686d732f6578616d706c65732f646179746f6e5f4c616e672e737667)](https://camo.githubusercontent.com/4fda44a24e8b4d972f5dc7951951d75090d1db3363b4589f9d4b10cfac3f0591/687474703a2f2f656d63636f6e76696c6c652e636f6d2f706f696e742d726564756374696f6e2d616c676f726974686d732f6578616d706c65732f646179746f6e5f4c616e672e737667)

### Zhao-Saalfeld

[](#zhao-saalfeld)

Added in version `1.2.0`.

```
use PointReduction\Common\Point,
    PointReduction\Algorithms\ZhaoSAalfeld;
$givenPoints = array(
    new Point(-84.158640, -39.822480),
    new Point(-84.159250, -39.820120),
    // ... and so one
);
$degree = 7;
$lookAhead = 7;
$reducer = new ZhaoSAalfeld($givenPoints);
$reducedPoints = $reducer->reduce($degree, $lookAhead);
```

The original polygon of 2151 points has been reduced to 1493.

[![Zhao-Saalfeld example](https://camo.githubusercontent.com/52760f22496aea05006b2552ed57918db0c7ce7c0b3aa3454c4fa84e07d1195e/687474703a2f2f656d63636f6e76696c6c652e636f6d2f706f696e742d726564756374696f6e2d616c676f726974686d732f6578616d706c65732f646179746f6e5f5a68616f5361616c66656c642e737667)](https://camo.githubusercontent.com/52760f22496aea05006b2552ed57918db0c7ce7c0b3aa3454c4fa84e07d1195e/687474703a2f2f656d63636f6e76696c6c652e636f6d2f706f696e742d726564756374696f6e2d616c676f726974686d732f6578616d706c65732f646179746f6e5f5a68616f5361616c66656c642e737667)

### Radial Distance

[](#radial-distance)

Added in version `1.2.0`.

```
use PointReduction\Common\Point,
    PointReduction\Algorithms\RadialDistance;
$givenPoints = array(
    new Point(-84.158640, -39.822480),
    new Point(-84.159250, -39.820120),
    // ... and so one
);
$tolerance = 0.0025;
$reducer = new RadialDistance($givenPoints);
$reducedPoints = $reducer->reduce($tolerance);
```

The original polygon of 2151 points has been reduced to 449.

[![Radial Distance example](https://camo.githubusercontent.com/ec906bad62cf9826b56fbaa4928a411ab8b579e1cbb78a8a9170f10167e1fcd4/687474703a2f2f656d63636f6e76696c6c652e636f6d2f706f696e742d726564756374696f6e2d616c676f726974686d732f6578616d706c65732f646179746f6e5f52616469616c44697374616e63652e737667)](https://camo.githubusercontent.com/ec906bad62cf9826b56fbaa4928a411ab8b579e1cbb78a8a9170f10167e1fcd4/687474703a2f2f656d63636f6e76696c6c652e636f6d2f706f696e742d726564756374696f6e2d616c676f726974686d732f6578616d706c65732f646179746f6e5f52616469616c44697374616e63652e737667)

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity46

Moderate usage in the ecosystem

Community17

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 92.9% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~387 days

Total

3

Last Release

3420d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1e6c723ba1f834133dd9a4ba54186905f7a6c93e6ea7fbe63c368c155eb7d4fb?d=identicon)[emcconville](/maintainers/emcconville)

---

Top Contributors

[![emcconville](https://avatars.githubusercontent.com/u/84594?v=4)](https://github.com/emcconville "emcconville (52 commits)")[![jmleroux](https://avatars.githubusercontent.com/u/1516770?v=4)](https://github.com/jmleroux "jmleroux (4 commits)")

---

Tags

Polygonpolylinepoint-reduction

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/emcconville-point-reduction-algorithms/health.svg)

```
[![Health](https://phpackages.com/badges/emcconville-point-reduction-algorithms/health.svg)](https://phpackages.com/packages/emcconville-point-reduction-algorithms)
```

###  Alternatives

[mjaschen/phpgeo

Simple Yet Powerful Geo Library

1.6k9.3M28](/packages/mjaschen-phpgeo)[emcconville/polyline-encoder

PHP Traits algorithms for Encoded Polyline &amp; Bing Point Compression

30334.4k1](/packages/emcconville-polyline-encoder)[mostafaznv/nova-map-field

Map Field for Laravel Nova

46107.9k](/packages/mostafaznv-nova-map-field)[funiq/geophp

Open-source native PHP library for doing geometry operations. Can read and write a wide variety of formats: (E)WKT, (E)WKB, TWKB, GeoJSON, KML, GPX, GeoRSS. Works with all Simple-Feature geometries (Point, LineString, Polygon...) and can be used to get centroids, bounding-boxes, area, etc.

22117.8k1](/packages/funiq-geophp)[david-r-edgar/rdp

Ramer–Douglas–Peucker algorithm for polyline simplification

2334.0k](/packages/david-r-edgar-rdp)[hannesvdvreken/pip

The Polygon class

1738.8k1](/packages/hannesvdvreken-pip)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
