Fast haversine distance calculation using Cython
Project description
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
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
File details
Details for the file haversine_distance-0.1.0.tar.gz.
File metadata
- Download URL: haversine_distance-0.1.0.tar.gz
- Upload date:
- Size: 59.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.27.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
39d55433ab75103e8420178e1af3f59d9366838818f7bd618cb4046a912dd847
|
|
| MD5 |
b2bcb108d33b21a6f1dcfeacb9806b9c
|
|
| BLAKE2b-256 |
83adc265371f23f62590e7248ff458424d6636653525f7859eb29f187632ef31
|