
=========
PyGeodesy
=========

A pure Python implementation of ``geodesy`` tools for various ellipsoidal
and spherical earth models using precision trigonometric, vector-based,
exact, elliptic and approximate methods for geodetic (lat-/longitude) and
geocentric (ECEF_ cartesian) coordinates.

Transcoded from `JavaScript originals`_ by *Chris Veness (C) 2005-2019*
and from several `C++ classes`_ by *Charles F.F. Karney (C) 2008-2021*
and published under the same `MIT License`_.

There are four modules for ellipsoidal earth models, *ellipsoidalExact*,
*-Karney*, *-Vincenty* and *-Nvector* and two for spherical ones,
*sphericalTrigonometry* and *-Nvector*.  Each module provides a geodetic
LatLon_ and a geocentric Cartesian_ class with methods and functions to
compute distance, surface area, perimeter, initial and final bearing,
intermediate and nearest points, circle intersections, path intersections,
trilateration (by intersection, by overlap and in 3d), conversions and
unrolling, among other things.  For more information and further details
see the documentation_, the descriptions of `Latitude/Longitude`_, Vincenty_
and `Vector-based`_ geodesy, the original `JavaScript source`_ or docs_
and *Karney*\'s Python geographiclib_ and `C++ GeographicLib`_.

Also included are modules for conversions to and from `Cassini-Soldner`_,
ECEF_ (Earth-Centered, Earth-Fixed cartesian), UPS_ (Universal Polar
Stereographic), UTM_ (Exact_ and Universal Transverse Mercator) and
`Web Mercator`_ (Pseudo-Mercator) coordinates, MGRS_ (NATO Military Grid
Reference System) and OSGR_ (British Ordinance Survery Grid Reference) grid
references, TRF_ (Terrestrial Reference Frames) and modules to encode and
decode EPSG_, Geohashes_, `Georefs (WGRS)`_ and `Garefs (GARS)`_ .

Other modules provide `Albers equal-area`_ projections, equidistant_
and other *azimuthal* projections, Lambert *conformal conic* projections
and positions, functions to clip a path or polygon of *LatLon* points
using the `Cohen-Sutherland`_, the `Liang-Barsky`_ and the
`Sutherland-Hodgman`_ methods, functions to simplify_ or linearize a
path of *LatLon* points (or a `numpy array`_), including implementations
of the `Ramer-Douglas-Peucker`_, the `Visvalingam-Whyatt`_ and the
`Reumann-Witkam`_ algorithms and modified versions of the former.  Other
classes interpolate_ the *height* of *LatLon* points and *Geoid* models
or compute various Frechet_ or Hausdorff_ distances.

Installation
============

To install PyGeodesy, type ``pip install PyGeodesy`` or ``easy_install
PyGeodesy`` in a terminal or command window.

Alternatively, download ``PyGeodesy-yy.m.d.zip`` from PyPI_ or GitHub_,
``unzip`` the downloaded file, ``cd`` to directory ``PyGeodesy-yy.m.d``
and type ``python[3] setup.py install``.

To run all PyGeodesy tests, type ``python[3] setup.py test`` or type
``python[3] test/run.py`` or type ``python[3] test/unitTestSuite.py``
before or after installation.

Dependencies
============

Installation of *Karney*\'s Python package geographiclib_ is optional,
but required to use modules ``ellipsoidalKarney`` and ``css``, ``azimuthal``
classes ``EquidistantKarney`` and ``GnomonicKarney`` and the
``HeightIDWkarney`` interpolator.

Both numpy_ and scipy_ must be installed for most ``Geoid...`` and
``Height...`` interpolators, except the ``HeigthIDW...`` ones.  Functions
``circum3``, ``jekel4_`` and ``trilaterate3d2/-5`` and the corresponding
``Cartesian``, ``LatLon``, ``Nvector`` and ``Vector3d`` methods require
numpy_.

Modules ``ellipsoidalGeodSolve`` and ``geodsolve`` and ``azimuthal``
classes ``EquidistantGeodSolve`` and ``GnomonicGeodSolve`` depend
on *Karney*\'s C++ utility GeodSolve_ to be executable.

Documentation
=============

In addition to the ``pygeodesy`` package, the PyGeodesy_ `distribution
files`_ contain the tests, the test results (on macOS only) and the
complete documentation_ generated by Epydoc_ using command line:
``epydoc --html --no-private --no-source --name=PyGeodesy --url=... -v
pygeodesy``.

Tests
=====

The tests have been run with Python 3.9.6 (with geographiclib_ 1.52),
Python 3.8.10 (with geographiclib_ 1.52, GeodSolve_ 1.51, numpy_ 1.19.2
and scipy_ 1.5.2) and macOS\' Python 2.7.16 (with GeodSolve_ 1.51 and
numpy_ 1.16.6), all on macOS 11.5.1 (10.16) Big Sur and in 64-bit (and
Intel) only.  The tests are run with and without ``lazy import`` for
Python 3 and with command line option ``-W always`` and environment
variable ``PYGEODESY_WARNINGS=on`` for all Python versions.  The results
of only those tests are included in the distribution files.

Test coverage has been measured with coverage_ 4.5.4 using Python 3.9.6
(with geographiclib_ 1.52), Python 3.8.10 (with geographiclib_ 1.52,
GeodSolve_ 1.51, numpy_ 1.19.2 and scipy_ 1.5.2) and macOS\' Python
2.7.16 (with GeodSolve_ 1.51 and numpy_ 1.16.6).  The complete coverage
report in HTML and a PDF summary are included in the distribution files.

The tests also ran with Python 3.8.0, 3.7.1, 3.6.7, 2.7.15 and PyPy_
7.1.1 (Python 3.6.1 and 2.7.13) (and geographiclib_ 1.52) on
`Ubuntu 16.04`_ and with Python 3.9.1 (and geographiclib_ 1.52) on
`Debian 9`_, all in 64-bit only and with Python 3.8.0, 3.7.5 and 2.7.17
(all with geographiclib_ 1.52) on `Windows Server 2012R2`_ in both 64-
and 32-bit.

A single-File and single-Directory application with ``pygeodesy`` has
been bundled using PyInstaller_ 3.4 and 64-bit Python 3.7.4 and 3.7.3
on macOS 10.13.6 High Sierra.

Previously, the tests were run with Python 3.9.0-5, 3.8.0-6, 3.7.2-6,
3.7.0, 3.6.2-5, 3.5.3, 2.7.13-17, 2.7.10 and 2.6.9 (and numpy_ 1.19.0,
1.16.5, 1.16.2, 1.15.2, 1.14.0, 1.13.1, 1.8.0rc1 or 1.6.2 and scipy_
1.5.0), PyPy_ 7.3.0 (Python 2.7.13 and 3.6.9), PyPy_ 6.0.0 (Python 2.7.13
and 3.5.3) and `Intel-Python`_ 3.5.3 (and numpy_ 1.11.3) on macOS 11.0-5
Big Sur, 10.15.3, 10.15.5-7 Catalina, macOS 10.14 Mojave, macOS 10.13.6
High Sierra, macOS 10.12 Sierra, MacOS X 10.11 El Capitan and/or MacOS X
10.10 Yosemite, with Pythonista_ 3.2 (with geographiclib 1.50 or 1.49
and numpy 1.8.0) on iOS 14.4.2, 11.4.1, 12.0-3 on iPad4, iPhone6 and/or
iPhone10, with Pythonista_ 3.1 on iOS 10.3.3, 11.0.3, 11.1.2 and 11.3 on
iPad4, all in 64-bit only and with 32-bit Python 2.7.14 on Windows 10 Pro
and 32-bit Python 2.6.6 on Windows XP SP3.

Notes
=====

All Python source code has been statically checked_ with PyChecker_,
PyFlakes_, PyCodeStyle_ (formerly Pep8) and McCabe_ using Python 2.7.18
and with Flake8_ using Python 3.9.6, both in 64-bit on macOS 11.5.1
(10.16) Big Sur (Intel).

For a summary of all *Karney*-based functionality in ``pygeodesy``, see
module karney_.

Some function and method names differ from the JavaScript version.  In such
cases documentation tag **JS name:** shows the original JavaScript name.

*Last updated: Aug 12, 2021.*

License
=======

``Copyright (C) 2016-2021 -- mrJean1 at Gmail -- All Rights Reserved.``

``Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:``

``The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.``

``THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.``

.. image:: https://Img.Shields.io/pypi/pyversions/PyGeodesy.svg?label=Python
  :target: https://PyPI.org/project/PyGeodesy
.. image:: https://Img.Shields.io/appveyor/ci/mrJean1/PyGeodesy.svg?branch=master&label=AppVeyor
  :target: https://CI.AppVeyor.com/project/mrJean1/PyGeodesy/branch/master
.. image:: https://Img.Shields.io/cirrus/github/mrJean1/PyGeodesy?branch=master&label=Cirrus
  :target: https://Cirrus-CI.com/github/mrJean1/PyGeodesy
.. image:: https://Img.Shields.io/travis/mrJean1/PyGeodesy.svg?branch=master&label=Travis
  :target: https://Travis-CI.com/mrJean1/PyGeodesy
.. image:: https://Img.Shields.io/badge/coverage-95%25-brightgreen
  :target: https://GitHub.com/mrJean1/PyGeodesy/blob/master/testcoverage.pdf
.. image:: https://Img.Shields.io/pypi/v/PyGeodesy.svg?label=PyPI
  :target: https://PyPI.org/project/PyGeodesy
.. image:: https://Img.Shields.io/pypi/wheel/PyGeodesy.svg
  :target: https://PyPI.org/project/PyGeodesy/#files
.. image:: https://img.shields.io/pypi/dm/PyGeodesy
  :target: https://PyPI.org/project/PyGeodesy
.. image:: https://Img.Shields.io/pypi/l/PyGeodesy.svg
  :target: https://PyPI.org/project/PyGeodesy

.. _Albers equal-area: https://GeographicLib.SourceForge.io/html/classGeographicLib_1_1AlbersEqualArea.html
.. _C++ classes: https://GeographicLib.SourceForge.io/html/annotated.html
.. _C++ GeographicLib: https://GeographicLib.SourceForge.io/html/index.html
.. _Cartesian: https://mrJean1.GitHub.io/PyGeodesy/docs/pygeodesy-Cartesian-attributes-table.html
.. _Cassini-Soldner: https://GeographicLib.SourceForge.io/html/classGeographicLib_1_1CassiniSoldner.html
.. _checked: https://GitHub.com/ActiveState/code/tree/master/recipes/Python/546532_PyChecker_postprocessor
.. _Cohen-Sutherland: https://WikiPedia.org/wiki/Cohen-Sutherland_algorithm
.. _coverage: https://PyPI.org/project/coverage
.. _Debian 9: https://Cirrus-CI.com/github/mrJean1/PyGeodesy/master
.. _distribution files: https://GitHub.com/mrJean1/PyGeodesy/tree/master/dist
.. _docs: https://www.Movable-Type.co.UK/scripts/geodesy/docs
.. _documentation: https://mrJean1.GitHub.io/PyGeodesy
.. _ECEF: https://WikiPedia.org/wiki/ECEF
.. _EPSG: https://www.EPSG-Registry.org
.. _Epydoc: https://PyPI.org/project/epydoc
.. _equidistant: https://GeographicLib.SourceForge.io/html/classGeographicLib_1_1AzimuthalEquidistant.html
.. _Exact: https://GeographicLib.SourceForge.io/html/classGeographicLib_1_1TransverseMercatorExact.html
.. _Flake8: https://PyPI.org/project/flake8
.. _Frechet: https://WikiPedia.org/wiki/Frechet_distance
.. _Garefs (GARS): https://WikiPedia.org/wiki/Global_Area_Reference_System
.. _GeodSolve: https://GeographicLib.SourceForge.io/html/utilities.html
.. _geographiclib: https://PyPI.org/project/geographiclib
.. _Geohashes: https://www.Movable-Type.co.UK/scripts/geohash.html
.. _Georefs (WGRS): https://WikiPedia.org/wiki/World_Geographic_Reference_System
.. _GitHub: https://GitHub.com/mrJean1/PyGeodesy
.. _Hausdorff: https://WikiPedia.org/wiki/Hausdorff_distance
.. _Intel-Python: https://software.Intel.com/en-us/distribution-for-python
.. _interpolate: https://docs.SciPy.org/doc/scipy/reference/interpolate.html
.. _JavaScript originals: https://GitHub.com/ChrisVeness/geodesy
.. _JavaScript source: https://GitHub.com/ChrisVeness/geodesy
.. _John P. Snyder: https://pubs.er.USGS.gov/djvu/PP/PP_1395.pdf
.. _karney: https://mrJean1.GitHub.io/PyGeodesy/docs/pygeodesy.karney-module.html
.. _Latitude/Longitude: https://www.Movable-Type.co.UK/scripts/latlong.html
.. _LatLon: https://mrJean1.GitHub.io/PyGeodesy/docs/pygeodesy-LatLon-attributes-table.html
.. _Liang-Barsky: https://www.CS.Helsinki.FI/group/goa/viewing/leikkaus/intro.html
.. _McCabe: https://PyPI.org/project/mccabe
.. _MGRS: https://www.Movable-Type.co.UK/scripts/latlong-utm-mgrs.html
.. _MIT License: https://OpenSource.org/licenses/MIT
.. _numpy: https://PyPI.org/project/numpy
.. _numpy array: https://docs.SciPy.org/doc/numpy/reference/generated/numpy.array.html
.. _OSGR: https://www.Movable-Type.co.UK/scripts/latlong-os-gridref.html
.. _PyChecker: https://PyPI.org/project/pychecker
.. _PyCodeStyle: https://PyPI.org/project/pycodestyle
.. _PyFlakes: https://PyPI.org/project/pyflakes
.. _PyGeodesy: https://PyPI.org/project/PyGeodesy
.. _PyInstaller: https://www.PyInstaller.org
.. _PyPI: https://PyPI.org/project/PyGeodesy
.. _PyPy: https://PyPy.org
.. _Pythonista: https://OMZ-Software.com/pythonista
.. _Ramer-Douglas-Peucker: https://WikiPedia.org/wiki/Ramer-Douglas-Peucker_algorithm
.. _Reumann-Witkam: https://psimpl.SourceForge.net/reumann-witkam.html
.. _scipy: https://PyPI.org/project/scipy
.. _simplify: https://Bost.Ocks.org/mike/simplify
.. _Sutherland-Hodgman: https://WikiPedia.org/wiki/Sutherland-Hodgman_algorithm
.. _TRF: http://ITRF.ENSG.IGN.FR
.. _Ubuntu 16.04: https://Travis-CI.com/mrJean1/PyGeodesy
.. _UPS: https://WikiPedia.org/wiki/Universal_polar_stereographic_coordinate_system
.. _UTM: https://www.Movable-Type.co.UK/scripts/latlong-utm-mgrs.html
.. _Vector-based: https://www.Movable-Type.co.UK/scripts/latlong-vectors.html
.. _Vincenty: https://www.Movable-Type.co.UK/scripts/latlong-vincenty.html
.. _Visvalingam-Whyatt: https://hydra.Hull.ac.UK/resources/hull:8338
.. _Web Mercator: https://WikiPedia.org/wiki/Web_Mercator
.. _Windows Server 2012R2: https://CI.AppVeyor.com/project/mrJean1/pygeodesy
