Negative results occurs when calculate crosstrack distance(distance between line segment and point on sphere)
By : Jordav
Date : March 29 2020, 07:55 AM
Hope that helps It can happen if the coordinates of (x,y) are in fact values under (x",y"). That doesn't mean that the value is negative, but that the substraction is always made in the same order:

finding the distance between a set of points using scipy.spatial.distance.cdist(X, Y) in python
By : Devanopy
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further Two solutions: calculate the complete matrix directly, and the access the qth column for the values between A and B[q]. code :
d = scipy.spatial.distance.cdist(A,B)
for q in range(len(B)):
y = d[:,q]
print y
for q in range(len(B)):
y = scipy.spatial.distance.cdist(A,[B[q]])
print y

python how to get proper distance value out of scipy condensed distance matrix
By : Carlo Monti
Date : March 29 2020, 07:55 AM
should help you out This vector is in condensed form. It enumerates all pairs of indices in a natural order (in your example 0,1 0,2 0,3 0,4 1,2 1,3 1,4 2,3 2,4 ) and yields the distance between the elements at these array entries. There is also the squareform function, which transforms the condensed form into a square matrix form (and vice versa). The square matrix form is exactly what you expect, i.e. at entry ij (row i, column j), it stores the distance between the ith and jth entry. For example, if you add print squareform(d) at the end of you code, the output will be: code :
array([[ 0., 3., 1., 4.],
[ 3., 0., 4., 1.],
[ 1., 4., 0., 5.],
[ 4., 1., 5., 0.]])

Distance transform with Manhattan distance  Python / NumPy / SciPy
By : Thomas
Date : March 29 2020, 07:55 AM

Scipy Sparse  distance matrix (Scikit or Scipy)
By : Waleed Ibrahim
Date : March 29 2020, 07:55 AM
it should still fix some issue First, you can't use KDTree and pdist with sparse matrix, you have to convert it to dense (your choice whether it's your option):

