PHPackages                             phdevutils/geo - 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. phdevutils/geo

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

phdevutils/geo
==============

Philippine geo utilities — representative coordinates for all PSGC cities/municipalities plus haversine distance, nearest-city, and within-radius helpers. Data from GeoNames (CC BY 4.0). Zero-dependency.

v0.1.0(1mo ago)02↓90%MITPHPPHP &gt;=8.1

Since Jun 3Pushed 1mo agoCompare

[ Source](https://github.com/kon2raya24/ph-geo-php)[ Packagist](https://packagist.org/packages/phdevutils/geo)[ RSS](/packages/phdevutils-geo/feed)WikiDiscussions main Synced 1w ago

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

phdevutils/geo
==============

[](#phdevutilsgeo)

[![Packagist Version](https://camo.githubusercontent.com/760b92861c6c0c6604a0309f108483f7f75d795eb946294d8e3792e1fcf6bc24/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f70686465767574696c732f67656f3f6c6162656c3d5061636b616769737426636f6c6f723d663238643161266c6f676f3d7061636b6167697374266c6f676f436f6c6f723d7768697465)](https://packagist.org/packages/phdevutils/geo)[![License: MIT](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](LICENSE)

Philippine **geo utilities** for PHP — a representative coordinate for **every PSGC city/municipality** plus **haversine distance**, **nearest-city**, and **within-radius** helpers. PHP companion to the npm package `@ph-dev-utils/geo`.

Coordinates are keyed by the same 6-digit PSGC `cityMunCode` as `phdevutils/core`, so they join cleanly.

```
composer require phdevutils/geo
```

Quick start
-----------

[](#quick-start)

```
use PhDevUtils\Geo\Geo;

Geo::findCoord('072217');            // ['name' => 'City of Cebu', 'lat' => 10.31, 'lng' => 123.89, ...]
Geo::findCoord('Cebu City');         // same — "City of X" / "X City" tolerant

Geo::distanceKm('133900', '072217'); // ~570.0  (Manila → Cebu, km)
Geo::distanceKm(['lat' => 14.6, 'lng' => 121.0], 'Makati'); // accepts raw lat/lng too

Geo::nearestCity('133900', 5);       // 5 nearest cities to Manila, nearest first (with 'distanceKm')
Geo::withinRadiusKm('133900', 30);   // every city/municipality within 30 km of Manila

Geo::listCoords(['region' => '07']); // all coordinates in Region VII (Central Visayas)
```

API
---

[](#api)

MethodReturns`Geo::listCoords($filter = [])``array` of coordinates — filter by `region` and/or `province` (`null` matches NCR / independent cities)`Geo::findCoord($query)`coordinate `array` or `null` — by 6-digit PSGC code or city name (`"City of X"` / `"X City"` tolerant)`Geo::distanceKm($a, $b)``float` or `null` — great-circle km; each arg is `['lat'=>,'lng'=>]` or a code/name`Geo::nearestCity($point, $n = 1)``array` — `n` nearest, nearest first (each with `distanceKm`)`Geo::withinRadiusKm($point, $km)``array` — all within `$km`, nearest first`Geo::meta()``array` — provenance + license note for the bundled dataEach coordinate array: `cityMunCode` (6-digit PSGC), `name`, `province` (4-digit code or `null` for NCR / independent cities), `region` (2-digit code), `lat` (float), `lng` (float), `points` (int — GeoNames postal points averaged into the centroid). `nearestCity` / `withinRadiusKm` results add a `distanceKm` (float) key.

A *point* argument is either a `['lat' => float, 'lng' => float]` array or a string PSGC code / city name resolvable via `Geo::findCoord`.

Data &amp; disclaimer
---------------------

[](#data--disclaimer)

Each coordinate is a **representative point** — the mean of the GeoNames postal-code points that map to the city/municipality — intended for distance/proximity work. It is **not** an official PSA centroid or a survey-grade location. Coordinates are derived from the [GeoNames](https://www.geonames.org) Philippines postal dump (**CC BY 4.0**); the ZIP → `cityMunCode` join is reused from `phdevutils/postal` and names/provinces/regions from the PSA Q4 2024 PSGC. See the `NOTICE` file for attribution.

License
-------

[](#license)

MIT. Bundled coordinate data © GeoNames, CC BY 4.0.

###  Health Score

34

—

LowBetter than 75% of packages

Maintenance90

Actively maintained with recent releases

Popularity2

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity32

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

Unknown

Total

1

Last Release

52d ago

### Community

Maintainers

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

---

Top Contributors

[![kon2raya24](https://avatars.githubusercontent.com/u/167972097?v=4)](https://github.com/kon2raya24 "kon2raya24 (2 commits)")

---

Tags

composercoordinatesgeophilippinesphpgeolatitudelongitudedistancecoordinatesphilippineshaversinegeonamespsgcfilipino

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/phdevutils-geo/health.svg)

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

###  Alternatives

[mjaschen/phpgeo

Simple Yet Powerful Geo Library

1.6k9.3M29](/packages/mjaschen-phpgeo)[data-values/geo

Geographical value objects, parsers and formatters

20654.5k22](/packages/data-values-geo)[php-coord/php-coord

PHPCoord is a PHP library to aid in handling coordinates. It can convert coordinates for a point from one system to another and also calculate distance between points.

109996.7k12](/packages/php-coord-php-coord)[laravie/geotools

Geo-related tools PHP 7+ library

18136.3k1](/packages/laravie-geotools)

PHPackages © 2026

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