PHPackages                             daveross/offline-country-reverse-geocoder - 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. daveross/offline-country-reverse-geocoder

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

daveross/offline-country-reverse-geocoder
=========================================

Determine which country a lat/long point falls in

1.1.1(10y ago)2325.8k↓24.6%6[4 issues](https://github.com/daveross/offline-country-reverse-geocoder/issues)[1 PRs](https://github.com/daveross/offline-country-reverse-geocoder/pulls)MITPHPPHP &gt;=5.3

Since Jun 1Pushed 7y ago2 watchersCompare

[ Source](https://github.com/daveross/offline-country-reverse-geocoder)[ Packagist](https://packagist.org/packages/daveross/offline-country-reverse-geocoder)[ RSS](/packages/daveross-offline-country-reverse-geocoder/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (6)Dependencies (1)Versions (7)Used By (0)

Offline Country Reverse Geocoder
================================

[](#offline-country-reverse-geocoder)

[![Latest Stable Version](https://camo.githubusercontent.com/09d5e4b0e510469cbf4ddd36fa73c59bde10b70a0a8d22764008d2727722bcc4/68747470733a2f2f706f7365722e707567782e6f72672f64617665726f73732f6f66666c696e652d636f756e7472792d726576657273652d67656f636f6465722f762f737461626c65)](https://packagist.org/packages/daveross/offline-country-reverse-geocoder) [![License](https://camo.githubusercontent.com/d9961df08d4d1a2164703b9afdce3b27760c6915b9b97a504565d5164ab24072/68747470733a2f2f706f7365722e707567782e6f72672f64617665726f73732f6f66666c696e652d636f756e7472792d726576657273652d67656f636f6465722f6c6963656e7365)](http://daveross.mit-license.org/) [![Build Status](https://camo.githubusercontent.com/c09e247e5657cc4774e3f3444f796962b0c4932400b1286659844d75e616014c/68747470733a2f2f7472617669732d63692e6f72672f64617665726f73732f6f66666c696e652d636f756e7472792d726576657273652d67656f636f6465722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/daveross/offline-country-reverse-geocoder)

Determine which country a latitude/longitude point falls in, returning an [ISO 3166-1](https://en.m.wikipedia.org/wiki/ISO_3166-1_alpha-2) two letter country code. All processing is done locally using a dataset of country borders without needing to connect to an API.

Uses the data file from

Installing
----------

[](#installing)

### With Composer [![Total Downloads](https://camo.githubusercontent.com/7e735b092b1d8376556cd351efc437702359794e9f7383b56b4dc71eb7fa4491/68747470733a2f2f706f7365722e707567782e6f72672f64617665726f73732f6f66666c696e652d636f756e7472792d726576657273652d67656f636f6465722f646f776e6c6f616473)](https://packagist.org/packages/daveross/offline-country-reverse-geocoder)

[](#with-composer-)

```
composer require daveross/offline-country-reverse-geocoder:~1.0.0

```

or add the dependency to your composer.json file manually:

```
"require": {
	"php": ">=5.3",
	"daveross/offline-country-reverse-geocoder": "~1.0.0"
}

```

### Without Composer

[](#without-composer)

Copy this library's files to wherever you put third-party libraries in your application. Include `src/offline-country-reverse-geocoder.php` from this library, and it'll load `polygons.properties` from the same directory.

Examples
--------

[](#examples)

```
echo 'Washington DC is in ' . \DaveRoss\OfflineCountryReverseGeocoder\get_country(-77.0164, 38.9047) . "\n";
echo 'Chicago is in ' . \DaveRoss\OfflineCountryReverseGeocoder\get_country(-87.6847, 41.8369) . "\n";
echo 'London is in ' . \DaveRoss\OfflineCountryReverseGeocoder\get_country( -0.12750, 51.50722 ) . "\n";
echo 'New Delhi is in ' . \DaveRoss\OfflineCountryReverseGeocoder\get_country( 77.12, 28.38 ) . "\n";
echo 'Sydney is in ' . \DaveRoss\OfflineCountryReverseGeocoder\get_country( 151.2073200, -33.8678500 ) . "\n";

```

\##Dataset

This library uses the world borders dataset from [thematicmapping.org](http://thematicmapping.org/downloads/world_borders.php). The data is stored in a properties file within the project that maps country codes to Well Known Text format polygons and multi-polygons. The dataset was converted to Well Known Text format by [GIS Stack Exchange user, elrobis](http://gis.stackexchange.com/a/17441).

\##License

All code is [MIT licensed](http://daveross.mit-license.org/)

See [why I contribute to open source software](https://davidmichaelross.com/blog/contribute-open-source-software/).

The data file src/polygons.properties is available under a [Creative Commons Attribution-Share Alike License](http://creativecommons.org/licenses/by-sa/3.0/) in accordance with the license from

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance17

Infrequent updates — may be unmaintained

Popularity39

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity62

Established project with proven stability

 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

6

Last Release

4004d ago

Major Versions

0.1.2 → 1.0.02015-06-01

### Community

Maintainers

![](https://www.gravatar.com/avatar/5d1863183f9f04c2a5157701577532d8cda92cb2009c9794b94ced1f5237b7d2?d=identicon)[daveross](/maintainers/daveross)

---

Top Contributors

[![kumy](https://avatars.githubusercontent.com/u/176794?v=4)](https://github.com/kumy "kumy (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/daveross-offline-country-reverse-geocoder/health.svg)

```
[![Health](https://phpackages.com/badges/daveross-offline-country-reverse-geocoder/health.svg)](https://phpackages.com/packages/daveross-offline-country-reverse-geocoder)
```

###  Alternatives

[voku/arrayy

Array manipulation library for PHP, called Arrayy!

4875.5M16](/packages/voku-arrayy)[proj4php/proj4php

A PHP-Class for geographic coordinates transformation using proj4 definitions, thanks to a translation from Proj4JS

1321.7M16](/packages/proj4php-proj4php)[spatie/html-element

Html rendering in php inspired by hyperscript

191108.9k3](/packages/spatie-html-element)[mekras/php-speller

PHP spell check library

68409.5k](/packages/mekras-php-speller)[gai871013/ip-location

纯真IP地址,composer包(解析QQWay.dat)

729.7k4](/packages/gai871013-ip-location)[gabrieliuga/laravel-nova-sidebar-links

Allow definition of custom links on Laravel Nova sidebar.

12194.8k](/packages/gabrieliuga-laravel-nova-sidebar-links)

PHPackages © 2026

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