PHPackages                             lxlang/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. lxlang/rdp

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

lxlang/rdp
==========

Ramer–Douglas–Peucker algorithm for polyline simplification

0.0.2(2y ago)04.1k↓50%UnlicensePHPPHP &gt;=8.0

Since Mar 27Pushed 2y agoCompare

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

READMEChangelogDependencies (1)Versions (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

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

 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

Every ~0 days

Total

2

Last Release

782d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b3b912d1e7ddec141833cd10b2e0ecf3a75ac57a52eb6718afe0de7f89831faa?d=identicon)[lxlang](/maintainers/lxlang)

---

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

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/lxlang-rdp/health.svg)

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

###  Alternatives

[david-r-edgar/rdp

Ramer–Douglas–Peucker algorithm for polyline simplification

2332.7k](/packages/david-r-edgar-rdp)[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)

PHPackages © 2026

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