Skip to main content

Overview

Unix Build Status Testing Coverage Status Scrutinizer Code Quality PyPI Version PyPI License

This library provides vectorized direct and inverse geodesic methods.

The motivation was to have the accurate and fast vectorized geodesic routines for sailboat routing project. There are few python libraries, with geographiclib being the most accurate and reliable. Haversine method, which is widely used as an example of fast inverse method can be vectorized rather easily, however the errors are expected to be at least 0.5%. There are no vectorized AND accurate options.

This library is based on numpy and uses Vincenty's formulae. It is heavily based on the Movable Type Scripts blog and Javascript Geodesy code.

Vincenty's inverse algorithm is accurate, but sensitive to nearly antipodal points. One approach would be to return NaN for such points, with the assumption that they are not frequently observed in practical applications, however as this discussion nicely pointed out the package cannot be complete if it cannot handle these situations. I found that the issue can be solved by relaxing one of convergence criteria, but it results in errors up to 0.25% vs geographiclib for these points.

So, instead, this library uses the vectorized Vincenty's formulae with geographiclib as a fallback for unconverged points.

See notebook for execution time comparisons vs geographiclib.

Direct method for 100,000 points

94.9 ms ± 25 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
vs
9.79 s ± 1.4 s per loop (mean ± std. dev. of 7 runs, 1 loop each)
Inverse method for 100,000 points

1.5 s ± 504 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
vs
24.2 s ± 3.91 s per loop (mean ± std. dev. of 7 runs, 1 loop each)

Setup

Requirements

  • Python 3.7+
  • Numpy
  • Geographiclib

Installation

Install it directly into an activated virtual environment:

pip install geovectorslib

Usage

After installation, the package can imported:

$ python
>>> from geovectorslib import direct, inverse
>>> direct(lats1, lon1, bearings, distances, ellipsoid='WGS84')
>>> inverse(lats1, lons1, lats2, lons2, ellipsoid='WGS84')
Latitudes in decimal degrees [-90; +90].
Longitudes in decimal degrees [-180; +180].
Bearings in decimal degrees [0; 360].
Distances in meters.

You can specify a different ellipsoid or leave blank to use WGS84. Available ellipsoid keywords are:

  • ETRS89
  • WGS84
  • GRS80
  • GRS67
  • Intl-1924
  • Clarke-1880
  • Airy-1830

References

Movable Type Scripts

Geodesy

Geopy

Geographiclib

Stackoverflow discussion

Metadata

Release files for geovectorslib 1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for geovectorslib 1.4
File Size Uploaded
geovectorslib-1.4.tar.gz 11.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for geovectorslib 1.4
File Interpreter ABI Platform
geovectorslib-1.4-py3-none-any.whl Python 3 none any Details

Total release size: 22.4 kB

Release files / geovectorslib-1.4.tar.gz

Download URL geovectorslib-1.4.tar.gz
Size 11.1 kB
Tags Source
SHA-256 checksum
How to use checksums
184ef681316a3f2c703696b1f7c7d2b7d61cda21eba68ffc58fe122ac123fe24
BLAKE2b-256 checksum
How to use checksums
17219405bd5cb7198189f5894a0dcd03d95c487e7d86827aaf886e3a82fcc4a6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.12 CPython/3.10.1 Linux/5.15.10-arch1-1

Release files / geovectorslib-1.4-py3-none-any.whl

Download URL geovectorslib-1.4-py3-none-any.whl
Size 11.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
575bb902400a30975551407a493642e153822cb696695f6b78f17d009d72921b
BLAKE2b-256 checksum
How to use checksums
98aba8c2c4cf109d954b08d2f9e0b69443a8dac53cd33183c7f862132bab11f7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.12 CPython/3.10.1 Linux/5.15.10-arch1-1

Release history Release notifications | RSS feed

This release

1.4 This release

2 release files

1.3

2 release files

1.2

2 release files

1.1

2 release files

1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page