PHPackages                             nikopeikrishvili/geojson - 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. nikopeikrishvili/geojson

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

nikopeikrishvili/geojson
========================

description

1.0.1(2y ago)73GPL-3.0-or-laterPHPPHP &gt;=8.1

Since Jan 21Pushed 2y ago1 watchersCompare

[ Source](https://github.com/nikopeikrishvili/GeoJson)[ Packagist](https://packagist.org/packages/nikopeikrishvili/geojson)[ RSS](/packages/nikopeikrishvili-geojson/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (4)Versions (3)Used By (0)

Validate GeoJson to [RFC 7946](https://datatracker.ietf.org/doc/html/rfc7946) standard
======================================================================================

[](#validate-geojson-to-rfc-7946-standard)

### Installation

[](#installation)

The library is published as a [package](https://packagist.org/packages/nikopeikrishvili/geojson) and is installable via [Composer](http://getcomposer.org/):

```
composer require nikopeikrishvili/geojson
```

Creating GeoJson Object
-----------------------

[](#creating-geojson-object)

You can create Feature object and extract GeoJson string from it, you need just provide Coordinates, for example :

### Polygon

[](#polygon)

```
$feature = new GeoJSON\FeatureTypes\Polygon([/**coordinates array**/]);
```

### Multi Polygon

[](#multi-polygon)

```
$feature = new GeoJSON\FeatureTypes\MultiPolygon([/**coordinates array**/]);
```

### Point

[](#point)

```
$feature = new GeoJSON\FeatureTypes\Point([/**coordinates array**/]);
```

### Multi Point

[](#multi-point)

```
$feature = new GeoJSON\FeatureTypes\MultiPoint([/**coordinates array**/]);
```

### LineString

[](#linestring)

```
$feature = new GeoJSON\FeatureTypes\LineString([/**coordinates array**/]);
```

### MultiLineString

[](#multilinestring)

```
$feature = new GeoJSON\FeatureTypes\MultiLineString([/**coordinates array**/]);
```

### Generate GeoJson String

[](#generate-geojson-string)

```
$geoJson = $feature->asGeoJson();
$geoJsonString = $geoJson->asString();
echo $geoJsonString.PHP_EOL;
```

```
{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Polygon",
        "coordinates": [
          [
            [
              -72.04315136683675,
              29.451187895050822
            ],
            [
              -72.04315136683675,
              27.849712263460177
            ],
            [
              -68.23275413868745,
              27.849712263460177
            ],
            [
              -68.23275413868745,
              29.451187895050822
            ],
            [
              -72.04315136683675,
              29.451187895050822
            ]
          ]
        ]
      }
    }
  ]
}
```

Examples :
----------

[](#examples-)

[Polygon](examples/create/create-polygon.php) - Create Polygon Feature
[Point](examples/create/create-point.php) - Create Point Feature
[MultiPolygon](examples/create/create-multipolygon.php) - Create MultiPolygon Feature
[MultiPoint](examples/create/create-multipoint.php) - Create MultiPoint Feature
[LineString](examples/create/create-linestring.php) - Create LineString Feature
[MultiLineString](examples/create/create-multilinestring.php) - Create MultiLineString Feature

### GeoJson as Object

[](#geojson-as-object)

You can use this library to validate GeoJson to [RFC 7946](https://datatracker.ietf.org/doc/html/rfc7946) standard

Currently, it supports following GeoJson types:
[Polygon](examples/polygon.php) - Polygon Feature
[Point](examples/point.php) - Point Feature
[MultiPolygon](examples/multipolygon.php) - MultiPolygon Feature
[MultiPoint](examples/multipoint.php) - MultiPoint Feature
[LineString](examples/linestring.php) - LineString Feature
[MultiLineString](examples/multilinestring.php) - MultiLineString Feature

Package supports stdclass, string and array as an input

```
// String Based
$point = '{"type":"Feature","properties":[],"geometry":{"type":"Point","coordinates":[-90,180]}}';
$geojson = new GeoJSON($point);

// Array Based
$geojson = new GeoJSON([
    'type' => 'Feature',
    'properties' => [],
    'geometry' => [
        'type' => 'Point',
        'coordinates' => [-90, 180]
    ]
]);
// StdClass Based
$point = '{"type":"Feature","properties":[],"geometry":{"type":"Point","coordinates":[-90,180]}}';
$geojson = new GeoJSON(json_decode($point));
```

Note: if your geojson starts with Feature instead of FeatureCollection, package will wrap it with FeatureCollection

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity51

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

Every ~5 days

Total

2

Last Release

834d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/282a01743f8086efacb711414ca6c53405ce637568dc48049a25c15ad0b5c908?d=identicon)[nikopeikrishvili](/maintainers/nikopeikrishvili)

---

Top Contributors

[![nikopeikrishvili](https://avatars.githubusercontent.com/u/10278664?v=4)](https://github.com/nikopeikrishvili "nikopeikrishvili (18 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/nikopeikrishvili-geojson/health.svg)

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

###  Alternatives

[snicco/better-wp-hooks

1118.6k2](/packages/snicco-better-wp-hooks)[thalidzhokov/exchange-rates-cbrf

ExchangeRatesCBRF Class to get exchange rates of the Central Bank of Russia

102.7k](/packages/thalidzhokov-exchange-rates-cbrf)

PHPackages © 2026

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