Questions tagged [haversine]

The haversine formula is an equation important in navigation, giving great-circle distances between two points on a sphere from their longitudes and latitudes.

429 questions
8
votes
2 answers

Interpreting sklearn haversine outputs to kilometers

I can't figure out how to interpret the outputs of the haversine implementations in sklearn (version 20.2) The documentation says,"Note that the haversine distance metric requires data in the form of [latitude, longitude] and both inputs and outputs…
flyingmeatball
  • 7,457
  • 7
  • 44
  • 62
8
votes
3 answers

Calculating Great-Circle Distance with SQLite

Here is my problem, I have a SQLite table with locations and latitudes / longitudes. Basically I need to: SELECT location, HAVERSINE(lat, lon) AS distance FROM location ORDER BY distance ASC; HAVERSINE() is a PHP function that should return the…
Alix Axel
  • 151,645
  • 95
  • 393
  • 500
8
votes
3 answers

Is Google Maps calculating the wrong distance?

I've managed to get two functions working to calculate distances between two point on a google map. One that I gleaned(stole) from various places on the web and the other using the GLatLng.distanceFrom method in the Google Maps API. The reason I'm…
gargantuan
  • 8,888
  • 16
  • 67
  • 108
7
votes
5 answers

Python calculate lots of distances quickly

I have an input of 36,742 points which means if I wanted to calculate the lower triangle of a distance matrix (using the vincenty approximation) I would need to generate 36,742*36,741*0.5 = 1,349,974,563 distances. I want to keep the pair…
mptevsion
  • 937
  • 8
  • 28
6
votes
3 answers

Distance-based JOIN given Latitude/Longitude

Given the following tables: table A (id, latitude, longitude) table B (id, latitude, longitude) how do I build an efficient T-SQL query that associates each row in A with the closest row in B? The ResultSet should contains all the rows in A and…
Marsellus Wallace
  • 17,991
  • 25
  • 90
  • 154
6
votes
2 answers

What earth radius should I use to calculate distances near the Poles?

I'm monitoring a GPS unit which is on it's way from Cape Discovery in Canada, to the North Pole. I need to keep track of the distance travelled and distance remaining each day, so I'm using the Haversine Formula, which I'm told is very accurate for…
gargantuan
  • 8,888
  • 16
  • 67
  • 108
6
votes
1 answer

Why Manhattan Distance with haversine formula for geolocalizations is not accurate? [Python]

I want to compute the "MANHATTAN DISTANCE" also called "CITY BLOCK DISTANCE" among pairs of coordinates with LAT, LNG. Following this post Manhattan Distance for two geolocations I had computed the distance using the haversine formula: source =…
piezzoritro
  • 141
  • 2
  • 14
6
votes
4 answers

Pairwise haversine distance calculation

I have two arrays with lat and long. I want to calculate distance between every pair of lat and long with every other pair of lat and long in the array. Here are my two arrays. lat_array array([ 0.33356456, 0.33355585, 0.33355585, 0.33401788, …
Neil
  • 7,937
  • 22
  • 87
  • 145
6
votes
1 answer

Vectorize haversine distance computation along path given by list of coordinates

I have a list of coordinates and can calculate a distance matrix among all points using the haversine distance metric. Coordinates come a as numpy.array of shape (n, 2) of (latitude, longitude) pairs: [[ 16.34576887 -107.90942116] [ 12.49474931…
Stefan
  • 41,759
  • 13
  • 76
  • 81
6
votes
2 answers

Haversine Formula Implementation on Arduino

I'm working on creating a geofence using GPS & Arduino. I want to implement the Haversine Formula to find the distance between two points, in order to compute it with the radius. The problem is I'm finding it hard to implement the Haversine Formula…
user3286992
  • 61
  • 1
  • 4
5
votes
5 answers

How to measure distance using Haversine formula with MySQL?

I get Latitude and Longitudes from Google Maps Reverse-Geocoding API and then I need something like this: mysql_query("SELECT users.*, ".mysql_distance_column($lat,$lng)." FROM users ORDER BY DISTANCE"; function mysql_distance_column($lat=40 ,…
Neo
  • 11,078
  • 2
  • 68
  • 79
5
votes
1 answer

Efficient computation of minimum of Haversine distances

I have a dataframe with >2.7MM coordinates, and a separate list of ~2,000 coordinates. I'm trying to return the minimum distance between the coordinates in each individual row compared to every coordinate in the list. The following code works on a…
Walt Reed
  • 1,336
  • 2
  • 17
  • 26
5
votes
1 answer

Haversine formula Unity

So I'm trying to use the haversine formula in Unity to get the distance between two different points (latitude and longitud given). The code is working (no errors) but I keep gettting a wrong result. I followed the entire formula so I don't really…
5
votes
2 answers

Product Lookup By Postal/Zip Code | Haversine Algorithm | Performance

I have an application that searches for items based on a postal code. When searching for the postal code, I return all products that are from that City/Neighborhood (done by parsing the postal/zip codes). I now need to sort these products based on…
Mark
  • 4,773
  • 8
  • 53
  • 91
5
votes
2 answers

VBA haversine formula

I am trying to implement Haversine formula into excel function. Its looks like this: Public Function Haversine(Lat1 As Variant, Lon1 As Variant, Lat2 As Variant, Lon2 As Variant) Dim R As Integer, dlon As Variant, dlat As Variant, Rad1 As…
banshe
  • 75
  • 2
  • 9
1
2
3
28 29