PHPackages                             mediasuitenz/overpass2geojson - 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. mediasuitenz/overpass2geojson

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

mediasuitenz/overpass2geojson
=============================

Convert overpass JSON to GeoJSON

v2.1.1(5y ago)132.1k3[2 issues](https://github.com/mediasuitenz/Overpass2Geojson/issues)MITPHP

Since Mar 17Pushed 5y ago14 watchersCompare

[ Source](https://github.com/mediasuitenz/Overpass2Geojson)[ Packagist](https://packagist.org/packages/mediasuitenz/overpass2geojson)[ RSS](/packages/mediasuitenz-overpass2geojson/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (6)Used By (0)

Overpass 2 GeoJSON
==================

[](#overpass-2-geojson)

[![Media Suite](https://camo.githubusercontent.com/d1401db37e5285bbe5870abcbfe275427eeec2f8323381ac56865b05b8384485/687474703a2f2f6d6564696173756974652e636f2e6e7a2f6d732d62616467652e706e67)](http://mediasuite.co.nz)

[![Build Status](https://camo.githubusercontent.com/6dd1d232807aee0ab88be419f0a845b1b42f052eafdcc3cbdd126b245d8b7b69/68747470733a2f2f7472617669732d63692e6f72672f6d6564696173756974656e7a2f4f766572706173733247656f6a736f6e2e737667)](https://travis-ci.org/mediasuitenz/Overpass2Geojson)

`composer require mediasuitenz/Overpass2Geojson`

PHP modules to convert Overpass API JSON output to GeoJSON format

**Note:** this currently only converts either OSM ways and their nodes into a FeatureCollection of Features that have LineString geometries, or OSM nodes into a FeatureCollection of Point features.

With the ways conversion, if any ways reference nodes that aren't also in the input, those nodes will be ignored. If there are less than 2 nodes for any way, that way will not produce a Feature as LineStrings must have more than 2 coordinates.

To create a Polygon instead of a LineString you can pass true as the 3rd argument to `Overpass2Geojson::convertWays`, or set `Overpass2Geojson::polygon = true;` before using the utility.

Example
-------

[](#example)

### Overpass query

[](#overpass-query)

```
[out:json][timeout:25];
// gather results
(
  // all with highway tag
  way["highway"]
  // within bounding box
  (-43.5594542,172.6998653,-43.5548322,172.708076);
  // recursively get all nodes for the resultant ways (contains the lat/lon whereas ways don't)
  node(w)->.x;
);
out;

```

### PHP

[](#php)

```
// Example from above
$url = 'http://overpass.osm.rambler.ru/cgi/interpreter?data=[out:json][timeout:25];%20(%20way[%22highway%22]%20(-43.5594542,172.6998653,-43.5548322,172.708076);%20node(w)-%3E.x;%20);%20out;';

// cURL the API
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, $url);
$osmJsonData = curl_exec($ch);

// convert accepts JSON string or array e.g. from json_decode($osmJsonData, true);

$geojson = Overpass2Geojson::convertWays($osmJsonData); // Returns JSON encoded string
$geojson = Overpass2Geojson::convertWays($osmJsonData, false); // Returns array with GeoJSON structure
$geojson = Overpass2Geojson::convertNodes($osmJsonData);
```

Example input (from overpass)

```
{
  "elements": [
    {
      "type": "node",
      "id": 31064347,
      "lat": -43.5309816,
      "lon": 172.6420391
    },
    {
      "type": "node",
      "id": 31813685,
      "lat": -43.5309652,
      "lon": 172.6396892,
      "tags": {
        "highway": "traffic_signals",
      }
    },
    {
      "type": "way",
      "id": 4830778,
      "nodes": [
        31064347,
        31813685
      ],
      "tags": {
        "highway": "residential",
        "maxspeed": "50",
        "name": "Worcester Street"
      }
    }
  ]
}
```

Example output from Overpass2Geojson::convertWays

```
{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "geometry": {
        "type": "LineString",
        "coordinates": [
          [
            172.6420391,
            -43.5309816
          ],
          [
            172.6396892,
            -43.5309652
          ]
        ]
      },
      "properties": {
        "highway": "residential",
        "maxspeed": "50",
        "name": "Worcester Street"
      }
    }
  ]
}
```

Example output from Overpass2Geojson::convertNodes

```
{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": [],
      "geometry": {
        "type": "Point",
        "coordinates": [
          172.6420391,
          -43.5309816
        ]
      }
    },
    {
      "type": "Feature",
      "properties": {
        "highway": "traffic_signals"
      },
      "geometry": {
        "type": "Point",
        "coordinates": [
          172.6396892,
          -43.5309652
        ]
      }
    }
  ]
}
```

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance17

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 81.3% 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 ~531 days

Total

5

Last Release

1954d ago

Major Versions

v1.1.0 → v2.0.02016-09-29

### Community

Maintainers

![](https://www.gravatar.com/avatar/14521eac3349c6b6ec15e6573757b8b37aa9fac2ee6e359c8d576125286a89aa?d=identicon)[matt-in-a-hat](/maintainers/matt-in-a-hat)

---

Top Contributors

[![matt-in-a-hat](https://avatars.githubusercontent.com/u/1852796?v=4)](https://github.com/matt-in-a-hat "matt-in-a-hat (26 commits)")[![anotheredward](https://avatars.githubusercontent.com/u/228527?v=4)](https://github.com/anotheredward "anotheredward (4 commits)")[![stevevance](https://avatars.githubusercontent.com/u/1330459?v=4)](https://github.com/stevevance "stevevance (2 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/mediasuitenz-overpass2geojson/health.svg)

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

###  Alternatives

[dragon-code/benchmark

Simple comparison of code execution speed between different options

11934.7k5](/packages/dragon-code-benchmark)

PHPackages © 2026

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