PHPackages                             david-r-edgar/rdp - 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. david-r-edgar/rdp

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

david-r-edgar/rdp
=================

Ramer–Douglas–Peucker algorithm for polyline simplification

0.0.1(10y ago)2332.7k↑18.2%7[1 issues](https://github.com/david-r-edgar/RDP-PHP/issues)Public DomainPHPPHP &gt;=5.3.0

Since May 2Pushed 3y ago1 watchersCompare

[ Source](https://github.com/david-r-edgar/RDP-PHP)[ Packagist](https://packagist.org/packages/david-r-edgar/rdp)[ Docs](https://github.com/david-r-edgar/RDP-PHP)[ RSS](/packages/david-r-edgar-rdp/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (3)Used By (0)

RDP-PHP
=======

[](#rdp-php)

PHP implementation of the [Ramer–Douglas–Peucker](http://en.wikipedia.org/wiki/Ramer%E2%80%93Douglas%E2%80%93Peucker_algorithm) algorithm for polyline simplification.

License: Public Domain

### Example simplified polyline

[](#example-simplified-polyline)

[![Example polyline before and after simplification](beforeAndAfter.png)](beforeAndAfter.png)

### Installation

[](#installation)

```
composer require david-r-edgar/rdp

```

### Example usage

[](#example-usage)

```
use davidredgar\polyline\RDP;

$line = array(
    array(150, 10),
    array(200, 100),
    array(360, 170),
    array(500, 280));

$rdpResult = RDP::RamerDouglasPeucker2d($line, 30);

```

`$rdpResult` will contain a resulting array with the reduced number of points. For this example:

```
$rdpResult == array(
    array(150, 10),
    array(200, 100),
    array(500, 280));

```

The second parameter to `RamerDouglasPeucker2d()` is epsilon, the maximum perpendicular distance for any point from the line between two adjacent points. Try replacing it with, say, 10 or 50 and observe the results.

### Use for geographic purposes

[](#use-for-geographic-purposes)

I originally implemented this in order to simplify a complex route on a map. Because I was doing this in Great Britain with OSGB36 coordinates, this worked.

However, be careful if you want to want to attempt this with other coordinate systems. The algorithm assumes cartesian coordinates on a 2D plane. Attempting to use latitudes and longitudes on the surface of a sphere will result in incorrect results. For approximate polyline simplification, the results *may* still be acceptable. As you approach the poles, errors will become more and more apparent: put simply, the degrees of longitude will become much closer to one another than the degrees of latitude, and so incorrect points will be chosen to be removed from the polyline.

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity38

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

Unknown

Total

1

Last Release

3668d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/dbd4574853303237ef7bf89fdcd9ba35a213a237a87348c3f2770309c81fd14c?d=identicon)[david-r-edgar](/maintainers/david-r-edgar)

---

Top Contributors

[![david-r-edgar](https://avatars.githubusercontent.com/u/10180144?v=4)](https://github.com/david-r-edgar "david-r-edgar (18 commits)")

---

Tags

geopolylineRamer-Douglas-PeuckerRamerDouglasPeucker

### Embed Badge

![Health badge](/badges/david-r-edgar-rdp/health.svg)

```
[![Health](https://phpackages.com/badges/david-r-edgar-rdp/health.svg)](https://phpackages.com/packages/david-r-edgar-rdp)
```

###  Alternatives

[mjaschen/phpgeo

Simple Yet Powerful Geo Library

1.6k8.6M22](/packages/mjaschen-phpgeo)[stevebauman/location

Retrieve a user's location by their IP Address

1.3k7.6M65](/packages/stevebauman-location)[jmikola/geojson

GeoJSON implementation for PHP

3109.0M77](/packages/jmikola-geojson)[geokit/geokit

Geo-Toolkit for PHP

251924.7k6](/packages/geokit-geokit)[brick/geo

GIS geometry library

245862.1k15](/packages/brick-geo)[geo-io/interface

Geo I/O base interfaces.

626.1M7](/packages/geo-io-interface)

PHPackages © 2026

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