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
0
votes
1 answer
Spherical distance between two points on Earth
I am trying to find distance between two points on Earth. But all I know is their latitude and longitude range(Both points lie in that range) and the x and y coordinates on the USA map. I am using data from this…

a_123
- 183
- 2
- 13
0
votes
1 answer
Inaccurate Result from Haversine's Bearing Calculation
I am trying to implement the Haversine Formula in a little GPS program I'm writing. The distance calculations appear to be spot-on. However, I believe the bearing is being computed in radians, and I don't know how to properly convert the result to…

programer8472
- 3
- 1
0
votes
2 answers
Given two lat/longs, how can I tell if they are within 1 mile of each other?
I'm trying to implement a very efficient check to see whether two points are within a mile of each other.
I only care whether they are within a mile - nothing else about the distance matters to me.
Because of that narrow focus, I am not looking for…

JosephStyons
- 57,317
- 63
- 160
- 234
0
votes
1 answer
How to calculate the distance between two latitude and longitude
I'm trying to calculate the distance between Vancouver and Toronto using their latitude and longitudes. I'm using haversine formula. I'm expecting a distance of around 4390 km. Can someone tell me what mistake I'm making. Here is my code:
user4591996
0
votes
1 answer
self join in spark with scala api
Earlier I posted a problem of self join in scala. I am trying to implement the same in Spark but not able to convert. Here is the problem and my code.
Input data set...
Proprty_ID, latitude, longitude, Address
123, 33.84, -118.39, null
234,…

Amit
- 45
- 8
0
votes
1 answer
GeoDjango and PostGIS distance query efficiency concerns
For example, if I want a query that says "show me all houses within 50km from here and order them from nearest to furthest", these are the questions and concerns I have:
Assuming we are using EC2 (application server with GeoDjango) and RDS…

davidtgq
- 3,780
- 10
- 43
- 80
0
votes
1 answer
Is it possible to use haversine in a laravel eloquent query?
I have created an api where I get offers that have 2 relationships in them:
venues belongsToMany offer (manyToMany)
days belongsToMany offer (manyToMany)
The offers then have the relationships synced and saved to them and in the returned json you…

M dunbavan
- 1,157
- 5
- 22
- 57
0
votes
2 answers
Not able to get perfect distance between two places
i have used Haversine for calculating distance between two location.
public static class Haversine {
static int Radius = 6371;
public static double haversine(double lat1, double lon1, double lat2,
double lon2) {
double…
user3997016
0
votes
3 answers
Get distance between 2 coordinates on globe
I tried to get distance between 2 coordinates using formula from here
The coordinates is 1.5378236000, 110.3372347000 and 1.5395056000, 110.3373156000.
Somehow the result turn out very different. I believed "dist1" is in KM but not sure about…

hidden
- 41
- 3
- 10
0
votes
0 answers
Select statement is not returning values for distances
I am trying to calculate and return the distances between some points.
Here is the complete MYSQL statement that I am using. I have tried multiple versions of this formula, and they all have similar results: returning zero result. Any thoughts on…

user-44651
- 3,924
- 6
- 41
- 87
0
votes
1 answer
Haversine Python Package in Django ORM query
I'm working in a Django App that stores lat and lng for users. I need to find nearby events for users based on their previously-defined radius. For both Users and Events, I store Latitude and Longitude in a MySQL database.
I found an example of a…

Gocht
- 9,924
- 3
- 42
- 81
0
votes
0 answers
MySQL - SELECT col, function(col) WHERE IN (..) returns same value
I have defined a function that calculates the nearest item using the haversine formula. This function works correctly when I execute the query in an ad-hoc fashion such as:
SELECT CONCAT(address, ", ", deadline, ", NC") AS addr FROM tblTickets…

xandout
- 173
- 2
- 14
0
votes
1 answer
How to calculate distance (NOT DISPLACEMENT) travelled using Haversine Formula?
I'm trying to code some JS that calculates the distance a user travels using the Haversine formula.
Now Haversine formula takes in the starting and current coordinates and gives out the separation between those two coordinates. That is however just…

Shubham Mehta
- 89
- 2
- 14
0
votes
1 answer
PHP Query issue in setting values?
Quick question. I've got a SQL query which works with my database. However, I am to sure how to set parameters in my PHP file so that it works with my query?
Any Ideas? I'm having trouble with the Set parameters in terms of php and making my query…

Ankhit Sharma
- 367
- 1
- 5
- 16
0
votes
3 answers
iOS GPS Distance Calculations between 2 locations
I created an app that shows the distance between 2 iOS devices. I got
the coordinates using GPSKit and computes the distance using ZFHaversine. Both of them are libraries from cocoapods.org.
Now my problem is even if the device are placed side by…

Richard
- 316
- 3
- 12