C RUBY-ON-RAILS MYSQL ASP.NET DEVELOPMENT RUBY .NET LINUX SQL-SERVER REGEX WINDOWS ALGORITHM ECLIPSE VISUAL-STUDIO STRING SVN PERFORMANCE APACHE-FLEX UNIT-TESTING SECURITY LINQ UNIX MATH EMAIL OOP LANGUAGE-AGNOSTIC VB6 MSBUILD

# How to calculate distance between two set of coordinates in meter?

By : prasinth.fistar
Date : November 21 2020, 07:31 AM
With these it helps You can form geodetic data in terms of 'kilometer' or 'meter' of unit using geodetic2ned() function but this needs Mapping Toolbox.
Now check the code below:
code :
``````pos1     = [32.22, 15.09];
pos2     = [32.45, 15.55];
h        = 0;                                 % // altitude
SPHEROID = referenceEllipsoid('wgs84', 'km'); % // Reference ellipsoid. You can enter 'km' or 'm'
[N, E]   = geodetic2ned(pos1(1), pos1(2), h, pos2(1), pos2(2), h, SPHEROID);
distance = norm([N, E]);
``````

Share :

## Modifying a Levenshtein distance function to calculate distance between two sets of x-y coordinates?

By : MXcZYz13
Date : March 29 2020, 07:55 AM
wish help you to fix your issue If I understood your question correctly, then you should completely remove the code for computing euclidian distance between two points!
First, let me restate your question:
code :
``````A = [ [1,1], [0,9], [3,3], [4,4] ]
B = [ [1,1], [2,2], [3,3], [4,4] ]
``````

## calculate distance between current coordinates and a list of coordinates

By : Robert McCormack
Date : March 29 2020, 07:55 AM
wish helps you To my konwledge wenn you read the value for this.places[i].Latitude this is not a Number so it would be necessary to convert this String to a number before you send it to the function or within the funktion.
Either with Number() or with parseFloat()

## Calculate distance between vector of coordinates in 1 df and single coordinates in other df

By : ColeBaraba
Date : March 29 2020, 07:55 AM
it should still fix some issue working with the sample data provided, I came to this data.table-approach
code :
``````library( data.table )
#set as data.tables
setDT(dfAB)
setDT(dfXY)
#melt to long format
dt1 <- melt( dfAB, measure.vars = names(dfAB) )[, c("x_AB","y_AB") := lapply( tstrsplit( value, ","), as.numeric ) ]
dt2 <- melt( dfXY, measure.vars = names(dfXY) )[, c("x_XY","y_XY") := lapply( tstrsplit( value, ","), as.numeric ) ]
#update join to get the coordinates to calculate distance with (join on Cx-value)
dt1[ dt2, `:=`( x_XY = i.x_XY, y_XY = i.y_XY ), on = .(variable) ]
#calculate eucledian distances
dt1[, distances := sqrt( (x_XY - x_AB )^2 + (y_XY - y_AB)^2 ) ]
``````
``````#     variable value x_AB y_AB x_XY y_XY distances
#  1:       C1   3,1    3    1    3    5  4.000000
#  2:       C1   2,1    2    1    3    5  4.123106
#  3:       C1   2,3    2    3    3    5  2.236068
#  4:       C1   2,2    2    2    3    5  3.162278
#  5:       C1   4,2    4    2    3    5  3.162278
#  6:       C1   2,4    2    4    3    5  1.414214
#  7:       C1   4,1    4    1    3    5  4.123106
#  8:       C1   3,3    3    3    3    5  2.000000
#  9:       C1   2,3    2    3    3    5  2.236068
# 10:       C1   3,1    3    1    3    5  4.000000
# 11:       C2   3,2    3    2    1    2  2.000000
# 12:       C2   3,1    3    1    1    2  2.236068
# 13:       C2   1,2    1    2    1    2  0.000000
# 14:       C2   1,2    1    2    1    2  0.000000
# 15:       C2   0,1    0    1    1    2  1.414214
# 16:       C2   1,4    1    4    1    2  2.000000
# 17:       C2   0,1    0    1    1    2  1.414214
# 18:       C2   1,0    1    0    1    2  2.000000
# 19:       C2   4,2    4    2    1    2  3.000000
# 20:       C2   5,1    5    1    1    2  4.123106
# 21:       C3   2,0    2    0    2    1  1.000000
# 22:       C3   3,2    3    2    2    1  1.414214
# 23:       C3   3,3    3    3    2    1  2.236068
# 24:       C3   1,1    1    1    2    1  1.000000
# 25:       C3   0,1    0    1    2    1  2.000000
# 26:       C3   6,3    6    3    2    1  4.472136
# 27:       C3   2,0    2    0    2    1  1.000000
# 28:       C3   4,2    4    2    2    1  2.236068
# 29:       C3   1,2    1    2    2    1  1.414214
# 30:       C3   3,0    3    0    2    1  1.414214
# 31:       C4   3,1    3    1    5    4  3.605551
# 32:       C4   3,1    3    1    5    4  3.605551
# 33:       C4   2,1    2    1    5    4  4.242641
# 34:       C4   3,1    3    1    5    4  3.605551
# 35:       C4   3,4    3    4    5    4  2.000000
# 36:       C4   2,1    2    1    5    4  4.242641
# 37:       C4   4,3    4    3    5    4  1.414214
# 38:       C4   0,2    0    2    5    4  5.385165
# 39:       C4   2,3    2    3    5    4  3.162278
# 40:       C4   2,5    2    5    5    4  3.162278
# 41:       C5   2,2    2    2    4    3  2.236068
# 42:       C5   3,1    3    1    4    3  2.236068
# 43:       C5   2,1    2    1    4    3  2.828427
# 44:       C5   3,1    3    1    4    3  2.236068
# 45:       C5   1,0    1    0    4    3  4.242641
# 46:       C5   2,0    2    0    4    3  3.605551
# 47:       C5   1,1    1    1    4    3  3.605551
# 48:       C5   1,1    1    1    4    3  3.605551
# 49:       C5   4,1    4    1    4    3  2.000000
# 50:       C5   2,1    2    1    4    3  2.828427
#     variable value x_AB y_AB x_XY y_XY distances
``````
``````#create id's to cast on
dt1[, id := rowidv( dt1, cols = "variable" ) ]
#cast to wide
dcast( dt1, id~variable, value.var = "distances" )

#    id       C1       C2       C3       C4       C5
# 1:  1 4.000000 2.000000 1.000000 3.605551 2.236068
# 2:  2 4.123106 2.236068 1.414214 3.605551 2.236068
# 3:  3 2.236068 0.000000 2.236068 4.242641 2.828427
# 4:  4 3.162278 0.000000 1.000000 3.605551 2.236068
# 5:  5 3.162278 1.414214 2.000000 2.000000 4.242641
# 6:  6 1.414214 2.000000 4.472136 4.242641 3.605551
# 7:  7 4.123106 1.414214 1.000000 1.414214 3.605551
# 8:  8 2.000000 2.000000 2.236068 5.385165 3.605551
# 9:  9 2.236068 3.000000 1.414214 3.162278 2.000000
#10: 10 4.000000 4.123106 1.414214 3.162278 2.828427
``````
``````dcast( dt1, rowidv( dt1, cols = "variable" )~variable, value.var = "distances" )[, -1]
``````

## Calculate 100 meter distance when the latitude and longitude is a known point

By : Tyler Madeley
Date : March 29 2020, 07:55 AM
I wish this help you A complete code for calculating the distance between two points given the latitude and longitude http://www.movable-type.co.uk/scripts/latlong.html

## How to calculate House distance with euclidean distance between two set of points (coordinates) with R

By : Mohamed Samir
Date : September 22 2020, 11:00 PM
I wish did fix the issue. There's also the dist() function. Note the rownames step is there to make the output more readable:
code :
``````rownames(df) <- df[['house']]
dist(df[, c('long', 'lat')])

# added round(..., 1) to make this output
a    b    c    d    e    f    g    h    i    j
b  5.0
c  8.2  4.1
d  8.1  3.2  2.2
e  5.0  3.2  3.6  4.5
f 12.0  8.9  5.0  7.1  7.1
g 14.6 12.2  8.5 10.6  9.8  3.6
h 10.2  7.8  4.5  6.7  5.4  2.2  4.5
i 12.0  8.9  5.0  7.1  7.1  0.0  3.6  2.2
j 18.1 14.9 10.8 12.5 13.2  6.1  4.5  8.0  6.1
x  8.1  5.7  3.0  5.1  3.2  4.0  6.7  2.2  4.0 10.0
``````
``````as.matrix(dist(df[, c('long', 'lat')]))[11, -11]

a    b    c    d    e    f    g    h    i    j
8.1  5.7  3.0  5.1  3.2  4.0  6.7  2.2  4.0 10.0

df\$distance_to_x <- as.matrix(dist(df[, c('long', 'lat')]))[11, ]

df

house long lat location distance_to_x
a     a   11  26     city      8.062258
b     b   15  29     city      5.656854
c     c   19  28     city      3.000000
d     d   18  30     city      5.099020
e     e   16  26     city      3.162278
f     f   23  25 district      4.000000
g     g   25  22 district      6.708204
h     h   21  24 district      2.236068
i     i   23  25 district      4.000000
j     j   29  24 district     10.049876
x     x   19  25     null      0.000000
``````
``````with(df, euclid(long, long[house =='x'], lat, lat[house == 'x']))
``````