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
4 answers

K-Means Distance Measure - Large Data and mixed Scales

I´ve a question regarding k-means clustering. We have a dataset with 120,000 observations and need to compute a k-means cluster solution with R. The problem is that k-means usually use Euclidean Distance. Our dataset consists of 3 continous…
user10256131
1
vote
0 answers

How calculate distance between projected UTM (with different zones) in Python

I have converted my lat. and long. to UTM using the UTM package using the following function: utm.from_latlon(lat, lon) For example, for the following coordinates in Massachusetts: a = (42.643614, -71.80304) I get this: (270205.1516852962,…
Seeeyaa
  • 11
  • 2
1
vote
0 answers

Calculating the distance between pairs using distances() function with HVDM metric in R

I am trying to calculate the distances between pairs using distances function in r language and I have selected HVDM as the matric. My code looks like this: library("UBL") df <-…
Mahin
  • 449
  • 2
  • 14
  • 25
1
vote
2 answers

How to measure distance with distanceTo in kilometers

I'm doing kinda running tracking app. My app already tracks my path and distance, but I can't understand what do those numbers in distance mean. Here are the screenshots(1,2,3). I want to get my distance in kilometers in this format DISTANCE FORMAT,…
JAGUAR
  • 21
  • 8
1
vote
0 answers

Horizontal and vertical distance for geospatial points in R?

My question is based upon this question. I would like to have horizontal and vertical distance shown as x and y below, between 2 geospatial points p1 and p2. Shall I find the M coordinate by : M$lat = p1$lat M$lon = p2$lon and then compute x and y…
Haribo
  • 2,071
  • 17
  • 37
1
vote
1 answer

How can I create a boxplot of within-group euclidian distances for grouped data?

Example data: set.seed(1234) a <- matrix(rnorm(250),nrow=25,ncol=10) fac <- as.factor(c(rep("A",8),rep("B",10),rep("C",7))) a.dist <- dist(a, "euclidian") boxplot(a.dist ~ fac) When I try to run boxplot(a.dist ~ fac), I get the following…
Antsushi
  • 167
  • 10
1
vote
1 answer

How to calculate distance between two points in 3D?

I have two lists. Each list has three lines. The coordinate system is (x,y,z) from up to down for each list. I tried to use array but it didn't work. Here are my codes. import numpy as np p1 = np.array([list(marker_11_x['11:-.X']),…
Ben Wang
  • 99
  • 3
  • 10
1
vote
1 answer

Android - Measure distance from camera

This is my first question in SO so I'll accept all the critics to improve my question. I am developing an Android App that needs to measure the distance to an object from the camera ( external camera, always in the same place ), with the help of…
Gerard E
  • 27
  • 9
1
vote
1 answer

SQL - Need to efficiently pair two entities by minimum distance apart within a group

For this example, I have one table which includes a list of people, a group category, and the location for each individual person (Long/Lat coordinates). A single individual can be in multiple groups. Here is an example table: Person Group Long …
Analyst Guy
  • 115
  • 13
1
vote
0 answers

Calculate length of segments on a line in kilometers in R

I have a GTFS from a bus network and would like to calculate the distance in kilometers between each pair of stops within a given line. I have two list of pairs (lon,lat). The first list represents the route and the second one the stops. It's…
Bondify
  • 341
  • 2
  • 5
1
vote
1 answer

How to specify argument `centers` for `flexclust::distEuclidean`?

I want to use flexclust::distEuclidean, but I'm not sure how centers should be specified. There are no examples given in the documentation at ?distance. So I checked the source of this function (which turns out short): function (x, centers) { …
jakes
  • 1,964
  • 3
  • 18
  • 50
1
vote
2 answers

Position from the latitude and longitude of nearby places

How can I calculate the latitude-longitude of a place, when the latitude-longitude information of its 3 nearby places, and the distances to the place are given? E.g, A,B and C are three places with latitude-longitude (x1,y1), (x2,y2) and (x3,y3).…
imsc
  • 7,492
  • 7
  • 47
  • 69
1
vote
1 answer

Shortest Distance Between 3 Points Along a Line Segment

I'm currently working on a pathfinding algorithm for navigation meshes. Skipping the details, I need to find an algorithm for finding the shortest distance between three points along a line segment. The path much travel from point A to B to C. A and…
1
vote
2 answers

using sklearn pairwise_distances to compute distance correlation between X and y

I am currently trying various methods: 1. Correlation. 2. Mutual Information. 3. Distance Correlation to find the strength of relationship between the variables in X and the dependent variable in y. Correlation is the fastest and simplest(1 hour on…
Shuvayan Das
  • 1,198
  • 3
  • 20
  • 40
1
vote
1 answer

I can't figure out how to find the Euclidean distance within a single dataframe

Here is the data I am working with: rdata <- data.frame(x = c(1, 2, 3, 4, 5), y=c(10, 12, 15, 19, 24)) ext <- rdist::rdist(rdata) View(ext) When I run this code, I receive the following table: As you can see from my markings, the correct…
Paul Ibrahim
  • 413
  • 1
  • 3
  • 14
1 2 3
99
100