The haversine formula is an equation important in navigation, giving great-circle distances between two points on a sphere from their longitudes and latitudes.
Questions tagged [haversine]
429 questions
5
votes
3 answers
Distance between two locations isn't right
I have used the algorithm on http://www.movable-type.co.uk/scripts/latlong.html to find the distance between two points.
My two points are
long1 = 51.507467;
lat1 = -0.08776;
long2 = 51.508736;
lat2 = -0.08612;
According to Movable Type Script the…

Ally
- 2,195
- 1
- 16
- 29
5
votes
2 answers
Equirectangular approximation in PHP
I'm trying to calculate the distance between two latitude/longitude coordinates using the equirectangular approximation formula in PHP, but I get different results than the haversine formula (which I know is correct) for certain longitude…

Martijn
- 3,696
- 2
- 38
- 64
5
votes
1 answer
The result by haversine formula is meter o kmeter?
I use the haversine formula to calculate the distance among the points. The result of this formula is in meter or in kmeter?
http://en.wikipedia.org/wiki/Haversine_formula
Anyone can help me?

doflamingo
- 77
- 1
- 1
- 9
5
votes
2 answers
Is it possible to implement the Haversine formula in Objective-C and call it from SQLite?
As I understand, SQLite doesn't have the math functions to properly implement the Haversine formula in straight SQL. I'm thinking this should be possible using an external function, with the implementation being in C.
The goal is to have a SQLite…

brianegge
- 29,240
- 13
- 74
- 99
4
votes
2 answers
Using the Haversine formula with PostgreSQL and PDO
On my site I'm trying to get locations nearby.
I'm trying to use the Haversine formula for this.
http://en.wikipedia.org/wiki/Haversine_formula
MySQL Great Circle Distance (Haversine formula)
Calculate zipcodes in range
I'm using the following…

PeeHaa
- 71,436
- 58
- 190
- 262
4
votes
1 answer
How can I introduce the radius in query radius-BallTree sklearn, with units of radians or km?
I'm working with latitude and longitude data. I've used BallTree because I have many rows (32000 rows) in the dataset. If I built the tree with haversine distance:
model_BTree = BallTree(np.array(points_sec_rad), metric='haversine')
and I transform…

DataScienceMA DMS
- 41
- 3
4
votes
2 answers
Finding two farthest objects between array of coordinates in PHP
I want to find two farthest objects (from each other) in my $user_devices array.
Every object of $user_devices has attributes: id, name, imei and coordinates. Ex.:
$user_devices = array(
'id' => '1',
'name' => 'First object',
'imei' =>…

senti
- 73
- 1
- 8
4
votes
1 answer
Calculating distance and velocity between time ordered coordinates
I have a csv containing locations (latitude,longitude) for a given user denoted by the id field, at a given time (timestamp). I need to calculate the distance and the velocity between a point and the successive point for each user. For example, for…

andrewr
- 784
- 13
- 31
4
votes
1 answer
Calculate the distance between two coordinates with Python
I have a map where they find several points (lat/long) and want to know the distance that exists between them.
So, given a set of lat/long coordinates, how can I compute the distance between them in python?

V. Andy
- 51
- 1
- 1
- 4
4
votes
2 answers
Join operation in Haversine formula
I am implementing Haversine formula in PHP as the follows
$result=mysqli_query($mysqli,"SELECT *,( 6371 * acos( cos( radians({$lat}) ) * cos( radians( `latitude` ) ) * cos( radians( `longitude` ) -radians({$lon}) ) +sin( radians({$lat}) ) * sin(…

Ashif Shereef
- 454
- 1
- 8
- 24
4
votes
0 answers
How to calculate distance between two latitude and longitude
I would like to calculate distance between 2 points of latitude and longitude i have read about Haversine Formula and Spherical Law of Cosines for calculate distance between two points but my main motive is get best location difference between 2…

androidXP
- 1,692
- 3
- 27
- 58
4
votes
2 answers
MySQL geospacial search using haversine formula returns null on same point
I'm trying to implement a geospacial search in a php application. Currently, I'm using the following query to find points within 10km of a given latitude and longitude:
SELECT * FROM (
SELECT *,
(6378.1 * ACOS(
…

Tudor Ravoiu
- 2,130
- 8
- 35
- 56
4
votes
1 answer
GeoCoordinate.GetDistanceTo using wrong radius for Earth?
I decompiled System.Device.Location.GeoCoordinate.GetDistanceTo(...), and found it uses the Haversine formula, which should specify the Earth's radius as one of the steps of calculation.
The radius specified in the decompiled code is 6376500.0…

David S.
- 5,965
- 2
- 40
- 77
3
votes
2 answers
Get nearest position with Haversine Formula in Spring
I have an entitiy which has two columns in the database like this:
@Column(name = "latitude", nullable = false)
private float currentPositionLatitude;
@Column(name = "longitude", nullable = false)
private float currentPositionLongitude;
And I have…

Okabe
- 85
- 2
- 16
3
votes
1 answer
How do I calculate the minimum geo distance between multiple point combinations faster in python?
I am trying to find the minimum distance between each customer to the store. Currently, there are ~1500 stores and ~670K customers in my data. I have to calculate the geo distance for 670K customers x 1500 stores and find the minimum distance for…

Jennifer Wu
- 31
- 3