Questions tagged [distance]

Distance is a numerical description of how far apart objects are.

In physics or everyday discussion, distance may refer to a physical length, or an estimation based on other criteria (e.g. "two counties over"). In mathematics, a distance function or metric is a generalization of the concept of physical distance. A metric is a function that behaves according to a specific set of rules, and provides a concrete way of describing what it means for elements of some space to be "close to" or "far away from" each other. Some example distance functions are:

  • Manhattan Distance (between two vectors)
  • Euclidean Distance (between two vectors)
  • Jaccard Distance (between two sets)
  • Hamming Distance (between two binary strings or bit vectors)

In most cases, "distance from A to B" is interchangeable with "distance between B and A".

For a somewhat deeper discussion see wikipedia.

3952 questions
1
vote
1 answer

How to get more precision for a computed distance in MySQL, without using geometric types?

I must compute the distance between an object (a city) and each of the several entries from a MySQL table I have (some restaurants). This city and the restaurants are located in a same country. The computed distance is used in order to show all the…
JarsOfJam-Scheduler
  • 2,809
  • 3
  • 31
  • 70
1
vote
1 answer

How to customise what is returned by proxy::dist with dtw distance function

I've got a list of time series: ex <- list(ts1 = structure(c(15.33, 46.83, 69.93, 79.59, 85.785, 78.132, 61.812, 189.108, 188.904, 159.936, 35.175, 62.37, 77.49, 85.785, 87.36, 17.952, 198.696, 198.084, 159.936, 157.692), .Dim = 5:4, .Dimnames =…
Kuba_
  • 886
  • 6
  • 22
1
vote
0 answers

Excel distance calculation by using Google Maps API key

I have been using this for couple of months without a problem. Now I am getting #VALUE in Excel all the time I try get the distance. What can be the problem? I have Google Maps KEY AIzaS.....I Request URL…
10101
  • 2,232
  • 3
  • 26
  • 66
1
vote
2 answers

distance measure used to calculate k nearest neighbour

I am reading about k nearest neighbour, and the distance measure given in the example is as below. It says Ri is the range of the i-th component. I am confused about which distance measure is used here? I understand Euclidean Distance but this…
user4046073
  • 821
  • 4
  • 18
  • 39
1
vote
1 answer

Loop over two Pandas dataframes and apply function counting airports within given distance of city

I have two pandas dataframes, the first containing cities and their respective coordinates, the other containing airports and their coordinates (examples below). I'd like to get a count for how many airports are within a certain distance (geodesic)…
1
vote
2 answers

Merge distance matrix results and original indices with Python Pandas

I have a panda df with list of bus stops and their geolocations: stop_id stop_lat stop_lon 0 1 32.183939 34.917812 1 2 31.870034 34.819541 2 3 31.984553 34.782828 3 4 31.888550 34.790904 …
Shakedk
  • 420
  • 6
  • 15
1
vote
0 answers

dist behaves differently in gpuMatrix, how to get the same result?

I am trying to optimize euclidian distance calculation between a set of points, when runing dist on a simple matrix, with x on first column and y on the second, like this: m <- matrix(c(3,4,5,6,7,1,2,3,4,5,6) , ncol=2) [,1] [,2] [1,] 3 …
1
vote
3 answers

Calculate coordinates of a point with given distances to two other points

If I have three points A, B, C and I know the distances between them and A is at 2D coordinates {0,0} and B is at {ab,0}, then what would be the formula to find the coordinates of the point C?
JustAMartin
  • 13,165
  • 18
  • 99
  • 183
1
vote
1 answer

Getting distance from longitude and latitude using Haversine's distance formula

I am working in a pandas dataframe and I am trying to get the distance from the longitude and latitude for each point for every identifier. Here's the dataframe currently: Identifier num_pts latitude longitude 0 …
Janeson00
  • 113
  • 9
1
vote
1 answer

Tidying messy coordinates for use in measurements

I have some rather messy degrees, decimal minutes coordinates (the source of which is out of my control) in the following format (see below). I am trying to work out the distance between the points ultimately. minlat <- "51 12.93257'" maxlat <-…
Jim
  • 558
  • 4
  • 13
1
vote
1 answer

How to pass two dataframe columns to scipy.spatial.distance.pdist

I have a dataframe with a name of a location in the index and 2 columns, Latitude and Longitude. data = {'LE0039': {'LATITUDE': 59.522583, 'LONGITUDE': 29.566056}, 'LE0073': {'LATITUDE': 59.287991, 'LONGITUDE': 31.369472}, 'LE0142':…
1
vote
1 answer

How many words between phrases in text?

I have a question, how count word between phrases in text? For example, I have the next text: Elon Musk is a technology entrepreneur and investor. He is the founder, CEO, and lead designer of SpaceX. Elon Musk has stated that the goals of SpaceX,…
m.k
  • 83
  • 7
1
vote
1 answer

GRG Nonlinear R

I want to transform my excel solver model into a model in R. I need to find 3 sets of coordinates which minimizes the distance to the 5 other given coordinates. I've made a program which calculates a distance matrix which outputs the minimal…
Maurice
  • 139
  • 1
  • 7
1
vote
2 answers

Shortest distance between a point and a line (Google Maps API issue?)

I am trying to find the straight distance from a point C to the beach. Beach line is defined by points A and B and with the Haversine formula I get the distance from C (my marker in Google Maps) to a point D in the AB beach line perpendicular to…
Alvaro
  • 182
  • 2
  • 13
1
vote
2 answers

Find the second nearest point in a dataset

I have 2 sets of latitude and longitude. A = [{'lat' :40.2877, 'lon' : -94.7913}, {'lat' :40.7171, 'lon' : -73.9664}, {'lat' :32.7052, 'lon' : -117.1897}, {'lat' :33.2388, 'lon' : -115.5045}, .... ] B = [{'lat' :47.7351, 'lon' : -117.3705}, {'lat'…
john ed
  • 331
  • 2
  • 7