Comments (4)
Hi, my math is far in my memory, but if rad
and deg
are angle units, so how do you convert a distance to an angle ? 🤔
from haversine.
To rephrase what I said : the input might be in rad or deg, but the output is actually a distance,
If I look at the scikit learn implementation of haversine that you referenced in #30 their output is also in kilometers:
scikitlearn:
>>> from sklearn.metrics.pairwise import haversine_distances
>>> from math import radians
>>> bsas = [-34.83333, -58.5166646]
>>> paris = [49.0083899664, 2.53844117956]
>>> bsas_in_radians = [radians(_) for _ in bsas]
>>> paris_in_radians = [radians(_) for _ in paris]
>>> result = haversine_distances([bsas_in_radians, paris_in_radians])
>>> result * 6371000/1000 # multiply by Earth radius to get kilometers
array([[ 0. , 11099.54035582],
[11099.54035582, 0. ]])
haversine:
>>> bsas = (-34.83333, -58.5166646)
>>> paris = (49.0083899664, 2.53844117956)
>>> haversine(bsas, paris)
11099.555687157774
from haversine.
An angle in radians is simply the distance on the unit-sphere. So to get the result in rad, you simply don't multiply with the earth radius. The dependence between angle and distance in linear (that is why the circumference of a circle is r * 2pi (where 2pi is a 360 deg angle))
Edit:
and as you see in the sklearn example the result of the haversine function is multiplied with the earth radius. The result
itself is in radians.
from haversine.
Fixed by #40
from haversine.
Related Issues (20)
- Reverse haversine HOT 2
- Add haversine cdist HOT 7
- Haversine will not import with Ubuntu 20.04 and Python 3.8.2 HOT 2
- Pycharm report error "Import Unit fails" HOT 5
- Cannot pip install version 1.0.x with latest (56.2.0+) version of setuptools HOT 1
- No longer py2 compatible HOT 1
- Compute bearing / cardinal informations between two points HOT 10
- What does Unit.DEGREE option return in haversine function? HOT 4
- Unable to install with pyton 3.10 HOT 5
- haversine raises an exception above 180 degrees latitude HOT 13
- Examples on README.md are incorrect HOT 1
- `inverse_haversine` precision for cardinal directions HOT 14
- last release is breaking my CI HOT 8
- Officially support Python 3.10 on PyPI HOT 1
- haversine_vector is no longer fast HOT 3
- Request: accept shapely geometries as inputs HOT 7
- Typo in repository `About` HOT 1
- Possible vectorization bug HOT 3
- [tests] failures against 32bit arches HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from haversine.