PHPackages                             neil20fc/phpgeo - 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. neil20fc/phpgeo

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

neil20fc/phpgeo
===============

Simple Geo Library

1.0.4(6y ago)023MITPHPPHP &gt;=7.0

Since Jun 6Pushed 6y agoCompare

[ Source](https://github.com/neil20fc/phpgeos)[ Packagist](https://packagist.org/packages/neil20fc/phpgeo)[ Docs](https://phpgeo.marcusjaschen.de/)[ RSS](/packages/neil20fc-phpgeo/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (5)Dependencies (5)Versions (6)Used By (0)

phpgeo - A Simple Geo Library for PHP
=====================================

[](#phpgeo---a-simple-geo-library-for-php)

phpgeo provides abstractions to geographical coordinates (including support for different ellipsoids) and allows you to calculate geographical distances between coordinates with high precision.

- [Requirements](#requirements)
- [Documentation](#documentation)
- [Installation](#installation)
- [Features](#features)
- [License](#license)
- [Examples/Usage](#examplesusage)
    - [Distance between two coordinates (Vincenty's Formula)](#distance-between-two-coordinates-vincentys-formula)
    - [Simplifying a polyline](#simplifying-a-polyline)
    - [Polygon contains a point (e.g. "GPS geofence")](#polygon-contains-a-point-eg-gps-geofence)
    - [Formatted output of coordinates](#formatted-output-of-coordinates)
        - [Decimal Degrees](#decimal-degrees)
        - [Degrees/Minutes/Seconds (DMS)](#degreesminutesseconds-dms)
        - [GeoJSON](#geojson)
- [Credits](#credits)

Requirements
------------

[](#requirements)

Minimum required PHP version is 7.0.

Documentation
-------------

[](#documentation)

The documentation is available at

API documentation is available as well:

Installation
------------

[](#installation)

Using [Composer](https://getcomposer.org), just add it to your `composer.json` by running:

```
composer require mjaschen/phpgeo

```

License
-------

[](#license)

Starting with version 2.0.0 phpgeo is licensed under the MIT license. Older versions were GPL-licensed.

Features
--------

[](#features)

**Info:** Please visit the **[documentation site](https://phpgeo.marcusjaschen.de/)** for complete and up-to-date documentation!

phpgeo provides the following features (follow the links for examples):

- abstractions of several geometry objects ([coordinate/point](https://phpgeo.marcusjaschen.de/#_coordinate), [line](https://phpgeo.marcusjaschen.de/#_line), [polyline/GPS track](https://phpgeo.marcusjaschen.de/#_polyline), [polygon](https://phpgeo.marcusjaschen.de/#_polygon)
- support for different [ellipsoids](https://phpgeo.marcusjaschen.de/#_ellipsoid), e. g. WGS-84
- [length/distance/perimeter calculations](https://phpgeo.marcusjaschen.de/#_distance_and_length)with different implementations (Haversine, Vincenty)
- [Geofence](https://phpgeo.marcusjaschen.de/#_geofence_2) calculation, i. e. answering the question "Is this point contained in that area/polygon?"
- [formatting and output](https://phpgeo.marcusjaschen.de/#_formatting_and_output) of geometry objects (GeoJSON, nice strings, e. g. `18° 54′ 41″ -155° 40′ 42″`)
- calculation of [bearing angle between two points](https://phpgeo.marcusjaschen.de/#_bearing_between_two_points)(spherical or with Vincenty's formula)
- calculation of a [destination point for a given starting point](https://phpgeo.marcusjaschen.de/#_distance_between_two_coordinates_vincentys_formula), bearing angle, and distance (spherical or with Vincenty's formula)
- calculation of the [perpendicular distance between a point and a line](https://phpgeo.marcusjaschen.de/#_perpendicular_distance)
- getting segments of a [polyline](https://phpgeo.marcusjaschen.de/#_segments)/[polygon](https://phpgeo.marcusjaschen.de/#_segments_2),
- [reversing direction](https://phpgeo.marcusjaschen.de/#_reverse_direction_2)of polyline/polygon

Examples/Usage
--------------

[](#examplesusage)

This list is incomplete, please visit the [documentation site](https://phpgeo.marcusjaschen.de/)for the full monty of documentation and examples!

### Distance between two coordinates (Vincenty's Formula)

[](#distance-between-two-coordinates-vincentys-formula)

Use the calculator object directly:

```
