Skip to main content

Pure Python geodesy tools

Project description

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

Transcoded from JavaScript originals by Chris Veness (C) 2005-2024 and from several C++ classes by Charles F.F. Karney (C) 2008-2024 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, forward and reverse azimuth, initial and final bearing, intermediate and nearest points, intersections of geodesic, great circle and rhumb lines, circle intersections and secants, 3-point resections, triangulation, 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), UTM (Universal Transverse Mercator and Exact), UPS (Universal Polar Stereographic) and Web Mercator (Pseudo-Mercator) coordinates, MGRS (Military Grid Reference System, UTM and UPS) 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 paths or polygons of LatLon points using the Cohen-Sutherland, Forster-Hormann-Popa, Greiner-Hormann, Liang-Barsky and Sutherland-Hodgman methods or to perform boolean operations between (composite) polygons, functions to simplify or linearize a path of LatLon points (or a numpy array), including implementations of the Ramer-Douglas-Peucker, Visvalingam-Whyatt and Reumann-Witkam algorithms and modified versions of the former. Other classes interpolate the Height of LatLon points and Geoid models or compute various Fréchet or Hausdorff distances.

Installation

To install PyGeodesy, type python[3] -m pip install PyGeodesy or python[3] -m easy_install PyGeodesy in a terminal or command window.

If the wheel PyGeodesy-yy.m.d-py2.py3-none-any.whl is missing in PyPI Download files, download the file from GitHub/dist. Install that with python[3] -m pip install <path-to-downloaded-wheel> and verify with python[3] -m pygeodesy.

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] 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 GeoidKarney and the HeigthIDW... ones.

Functions and LatLon methods circin6, circum3, circum4_, soddy4, trilaterate3d2 and trilaterate5 do and modules auxilats and rhumb may require numpy.

Modules ellipsoidalGeodSolve and geodsolve and azimuthal classes EquidistantGeodSolve and GnomonicGeodSolve depend on Karney's C++ utility GeodSolve to be executable and set with env variable PYGEODESY_GEODSOLVE or with property Ellipsoid.geodsolve.

Class Intersectool in module geodesici needs Karney's C++ utility IntersectTool to be executable and set with env variable PYGEODESY_INTERSECTTOOL.

To compare MGRS results from modules mgrs and testMgrs with Karney's C++ utility GeoConvert, the latter must be executable and set with env variable PYGEODESY_GEOCONVERT.

Module rhumbsolve needs Karney's C++ utility RhumbSolve to be executable and set with env variable PYGEODESY_RHUMBSOLVE or with property Ellipsoid.rhumbsolve.

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 ran with Python 3.13.0 (with geographiclib 2.0), 3.12.7 (with geographiclib 2.0, numpy 2.1.0, scipy 1.14.1, GeodSolve 2.3, IntersectTool 2.3 and RhumbSolve 2.3), 3.11.5 (with geographiclib 2.0, numpy 1.24.2 and scipy 1.10.1), Python 3.10.8 (with geographiclib 2.0, numpy 1.23.3, scipy 1.9.1, GeoConvert 2.3, GeodSolve 2.3), Python 3.9.6 and Python 2.7.18 (with geographiclib 1.50, numpy 1.16.6, scipy 1.2.2, GeoConvert 2.3, GeodSolve 2.3, IntersectTool 2.3 and RhumbSolve 2.3), all on macOS 14.6.1 Sonoma in 64-bit.

All tests ran with and without lazy import for Python 3 and with command line option -W default and env variable PYGEODESY_WARNINGS=on for all Python versions. The results of those tests are included in the distribution files.

Python 3.13.0, 3.12.7, 3.11.5 and 3.10.8 run on Apple M1 Silicon (arm64), natively. Python 2.7.18 runs on Intel (x86_64) or Intel emulation ("arm64_x86_64", see function pygeodesy.machine).

Test coverage has been measured with coverage 7.6.1 using Python 3.13.0, 3.12.7, 3.11.5 and 3.10.8. The complete coverage report in HTML and a PDF summary are included in the distribution files.

The tests also ran with Python 3.13.0 (and geographiclib 2.0) on Debian 12 in 64-bit only and with Python 3.12.5 (and geographiclib 2.0) on Windows 2019Server in 64-bit only and with Python 2.7.18 (and with geographiclib 1.52) on Windows 10 in 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.12.0-6, 3.11.2-4, 3.10.1-7, 3.9.1, 3.8.7, 3.7.1, 2.7.15, PyPy 7.3.12 (Python 3.10.12), 7.3.1 (Python 3.6.9) and PyPy 7.1.1 (Python 2.7.13) (and geographiclib 1.52, numpy 1.16.3, 1.16.4, 1.16.6, 1.19.0, 1.19.4, 1.19.5 or 1.22.4 and scipy 1.2.1, 1.4.1, 1.5.2 or 1.8.1) on Ubuntu 16.04, with Python 3.10.0-1, 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 14.0-5 Sonoma, 13.0-5.2 Ventura, 12.1-6 Monterey, 11.0-5.2-6.1 Big Sur (aka 10.16), 10.15.3, 10.15.5-7 Catalina, 10.14 Mojave, 10.13.6 High Sierra and 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, iPhone10 and/or iPhone12, 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 Server 2012R2, 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.11.5, both in 64-bit on macOS 14.6.1 Sonoma.

For a summary of all Karney-based functionality in pygeodesy, see module karney.

Last updated: Nov 11, 2024.

License

Copyright (C) 2016-2024 – 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.

https://Img.Shields.io/pypi/pyversions/PyGeodesy.svg?label=Python https://Img.Shields.io/pypi/v/PyGeodesy.svg?label=PyPI https://Img.Shields.io/appveyor/ci/mrJean1/PyGeodesy.svg?branch=master&label=AppVeyor https://Img.Shields.io/cirrus/github/mrJean1/PyGeodesy?branch=master&label=Cirrus https://Img.Shields.io/badge/coverage-95%25-brightgreen https://Img.Shields.io/pypi/wheel/PyGeodesy.svg https://Img.Shields.io/pypi/l/PyGeodesy.svg https://img.shields.io/pypi/dm/PyGeodesy

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

PyGeodesy-24.11.11.zip (9.1 MB view details)

Uploaded Source

Built Distribution

PyGeodesy-24.11.11-py2.py3-none-any.whl (1.0 MB view details)

Uploaded Python 2 Python 3

File details

Details for the file PyGeodesy-24.11.11.zip.

File metadata

  • Download URL: PyGeodesy-24.11.11.zip
  • Upload date:
  • Size: 9.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.8

File hashes

Hashes for PyGeodesy-24.11.11.zip
Algorithm Hash digest
SHA256 275979e84cd6e3bd86158892b66a339a5fb34035f5363040e1702506b857c326
MD5 48979692fb60e3067190e150ba0c5aa8
BLAKE2b-256 b2f622aab8d7262c51f137db4cd815eb09766bbf9836c77f453bfecd2b0ee074

See more details on using hashes here.

File details

Details for the file PyGeodesy-24.11.11-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for PyGeodesy-24.11.11-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 d1f5b0a2c29a49abfd1cefda0f1c66fc17612e04cb76a0738c447f83b14641ea
MD5 66a40865cdef80b806445fdada32b9fc
BLAKE2b-256 452bb4af85fb9dd3734d67fedc92ea723416ab6493993bac3eb90f6bad8a6a14

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page