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
haversine_distance-0.1.0.tar.gz 59.0 kB Details

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

Release history Release notifications | RSS feed

This release

0.1.0 This release

1 release file

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