Skip to main content

Haversine Distance

A minimal Python package providing a single function to calculate the Great-circle distance distance between two points on the Earth’s surface.

The calculation is implemented in Cython for efficiency, offering faster performance than a pure Python version.

Features

  • Fast: Compiled C extension using libc.math.
  • Lightweight: No external runtime dependencies (only requires a C compiler for building).
  • Simple API: Callable module interface.

Installation

You need a C compiler installed (GCC, MSVC, or Clang) to build this package.

From PyPI

pip install haversine-distance

From Source

You need a C compiler installed (GCC, MSVC, or Clang) to build this package.

pip install .

Usage

The package is designed to be callable directly as a module.

Input Arguments

The function expects coordinates in Degrees.

Note: The signature follows (longitude, latitude) order based on the underlying calculation.

import haversine_distance

# New York (74.0060° W, 40.7128° N)
lon1, lat1 = -74.0060, 40.7128

# London (0.1278° W, 51.5074° N)
lon2, lat2 = -0.1278, 51.5074

# Calculate distance
distance_meters = haversine_distance(lon1, lat1, lon2, lat2)

print(f"Distance: {distance_meters / 1000:.2f} km")
# Output: Distance: 5570.22 km

License

MIT

Metadata

Release files for haversine-distance 0.1.0

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

Source distribution (sdist)

Source distribution for haversine-distance 0.1.0
File Size Uploaded Provenance Actions
haversine_distance-0.1.0.tar.gz 59.0 kB Without provenance Details for haversine_distance-0.1.0.tar.gz

Release files / haversine_distance-0.1.0.tar.gz

Download URL haversine_distance-0.1.0.tar.gz
Size 59.0 kB
Tags Source
SHA-256 checksum
How to use checksums
39d55433ab75103e8420178e1af3f59d9366838818f7bd618cb4046a912dd847
BLAKE2b-256 checksum
How to use checksums
83adc265371f23f62590e7248ff458424d6636653525f7859eb29f187632ef31
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-httpx/0.27.2

Security for haversine-distance 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

1 release file No provenance

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