All Projects → mapado → Haversine

mapado / Haversine

Licence: mit
Calculate the distance bewteen 2 points on Earth

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Haversine

erkir
Երկիր (Erkir) - a C++ library for geodesic and trigonometric calculations
Stars: ✭ 26 (-84.34%)
Mutual labels:  distance, earth
Geocalc
Helper classes to calculate Earth distances, bearing, etc.
Stars: ✭ 88 (-46.99%)
Mutual labels:  earth, distance
Distance
This Distance PHP class can calculate the distance between two latitude/longitude locations using Math functions in PHP. No external API's are called.
Stars: ✭ 33 (-80.12%)
Mutual labels:  distance
Terrarium
Replica of the Earth in Minecraft
Stars: ✭ 117 (-29.52%)
Mutual labels:  earth
Geolocation Python
Geolocation is simple google maps api for python users. This application allows you to get information about given location Application returns such information as: country, city, route/street, street number, reverse geocode, lat and lng, travel distance and time for a matrix of origins and destinations.
Stars: ✭ 77 (-53.61%)
Mutual labels:  distance
Himawari 8 Chrome
🛰 Experience the latest image from the Himawari, GOES, Meteosat, and DSCOVR satellites
Stars: ✭ 48 (-71.08%)
Mutual labels:  earth
Stopwords
Removes most frequent words (stop words) from a text content. Based on a Curated list of language statistics.
Stars: ✭ 83 (-50%)
Mutual labels:  distance
Foucluster
FouCluster compute distance among songs in frequency domains, and operate with clusters
Stars: ✭ 15 (-90.96%)
Mutual labels:  distance
Stereo Vision
This program has been developed as part of a project at the University of Karlsruhe in Germany. The final purpose of the algorithm is to measure the distance to an object by combining two webcams and use them as a Stereo Camera.
Stars: ✭ 160 (-3.61%)
Mutual labels:  distance
Ahrs
Attitude and Heading Reference Systems in Python
Stars: ✭ 75 (-54.82%)
Mutual labels:  earth
Unity3d Globe
Unity3D Implementation of Chrome Experiment WebGL Globe
Stars: ✭ 115 (-30.72%)
Mutual labels:  earth
Sweet
Official repository for Semantic Web for Earth and Environmental Terminology (SWEET) Ontologies
Stars: ✭ 69 (-58.43%)
Mutual labels:  earth
Geo Maps
🗺 High Quality GeoJSON maps programmatically generated.
Stars: ✭ 1,098 (+561.45%)
Mutual labels:  earth
Deepdiff
Deep Difference and search of any Python object/data.
Stars: ✭ 985 (+493.37%)
Mutual labels:  distance
Distancepicker
Custom UIKit control to select a distance with a pan gesture, written in Swift
Stars: ✭ 118 (-28.92%)
Mutual labels:  distance
Nlp xiaojiang
自然语言处理(nlp),小姜机器人(闲聊检索式chatbot),BERT句向量-相似度(Sentence Similarity),XLNET句向量-相似度(text xlnet embedding),文本分类(Text classification), 实体提取(ner,bert+bilstm+crf),数据增强(text augment, data enhance),同义句同义词生成,句子主干提取(mainpart),中文汉语短文本相似度,文本特征工程,keras-http-service调用
Stars: ✭ 954 (+474.7%)
Mutual labels:  distance
Earthlab.github.io
A site dedicated to tutorials, course and other learning materials and resources developed by the Earth Lab team
Stars: ✭ 62 (-62.65%)
Mutual labels:  earth
Himawari Bg
🌏 Set the latest image from Himawari 8 as your desktop background.
Stars: ✭ 81 (-51.2%)
Mutual labels:  earth
Textdistance
Compute distance between sequences. 30+ algorithms, pure python implementation, common interface, optional external libs usage.
Stars: ✭ 2,575 (+1451.2%)
Mutual labels:  distance
Himawari.js
Download real-time images of Earth from the Himawari-8 satellite
Stars: ✭ 1,763 (+962.05%)
Mutual labels:  earth

Haversine Build Status

Calculate the distance (in various units) between two points on Earth using their latitude and longitude.

Installation

$ pip install haversine

Usage

Calculate the distance between Lyon and Paris

from haversine import haversine, Unit

lyon = (45.7597, 4.8422) # (lat, lon)
paris = (48.8567, 2.3508)

haversine(lyon, paris)
>> 392.2172595594006  # in kilometers

haversine(lyon, paris, unit=Unit.MILES)
>> 243.71201856934454  # in miles

# you can also use the string abbreviation for units:
haversine(lyon, paris, unit='mi')
>> 243.71201856934454  # in miles

haversine(lyon, paris, unit=Unit.NAUTICAL_MILES)
>> 211.78037755311516  # in nautical miles

The haversine.Unit enum contains all supported units:

import haversine

print(tuple(haversine.Unit))

outputs

(<Unit.FEET: 'ft'>, <Unit.INCHES: 'in'>, <Unit.KILOMETERS: 'km'>,
 <Unit.METERS: 'm'>, <Unit.MILES: 'mi'>, <Unit.NAUTICAL_MILES: 'nmi'>)

Performance optimisation for distances between all points in two vectors

You will need to add numpy in order to gain performance with vectors.

You can then do this:

from haversine import haversine_vector, Unit

lyon = (45.7597, 4.8422) # (lat, lon)
paris = (48.8567, 2.3508)
new_york = (40.7033962, -74.2351462)

haversine_vector([lyon, lyon], [paris, new_york], Unit.KILOMETERS)

>> array([ 392.21725956, 6163.43638211])

It is generally slower to use haversine_vector to get distance between two points, but can be really fast to compare distances between two vectors.

Combine matrix

You can generate a matrix of all combinations between coordinates in different vectors by setting comb parameter as True.

from haversine import haversine_vector, Unit

lyon = (45.7597, 4.8422) # (lat, lon)
london = (51.509865, -0.118092)
paris = (48.8567, 2.3508)
new_york = (40.7033962, -74.2351462)

haversine_vector([lyon, london], [paris, new_york], Unit.KILOMETERS, comb=True)

>> array([[ 392.21725956,  343.37455271],
 	  [6163.43638211, 5586.48447423]])

The output array from the example above returns the following table:

Paris New York
Lyon Lyon <-> Paris Lyon <-> New York
London London <-> Paris London <-> New York

By definition, if you have a vector a with n elements, and a vector b with m elements. The result matrix M would be $n x m$ and a element M[i,j] from the matrix would be the distance between the ith coordinate from vector a and jth coordinate with vector b.

Contributing

Clone the project.

Install pipenv.

Run pipenv install --dev

Launch test with pipenv run pytest

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].