# 10 examples of 'python calculate distance between all points' in Python

Every line of 'python calculate distance between all points' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

## All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
``299def distance_between_points(point_a, point_b):300    """301302    Vectorized Euclidean Distance303304    :param point_a:305    :param point_b:306    :return:307    """308    return np.sqrt(np.sum((np.array(point_a) - np.array(point_b))**2))``
``53def _py_distance(point1, point2):54    '''55        Calculating great-circle distance56        (see https://en.wikipedia.org/wiki/Great-circle_distance)57    '''58    lon1, lat1 = (radians(coord) for coord in point1)59    lon2, lat2 = (radians(coord) for coord in point2)6061    dlon = fabs(lon1 - lon2)62    dlat = fabs(lat1 - lat2)6364    numerator = sqrt(65        (cos(lat2)*sin(dlon))**2 +66        ((cos(lat1)*sin(lat2)) - (sin(lat1)*cos(lat2)*cos(dlon)))**2)6768    denominator = (69        (sin(lat1)*sin(lat2)) +70        (cos(lat1)*cos(lat2)*cos(dlon)))7172    c = atan2(numerator, denominator)73    return EARTH_MEAN_RADIUS*c``
``10def distance(x1, y1, x2, y2):11    """Return the distance between the points (x1, y1) and (x2, y2)"""12    t1 = (x1 - x2)13    t2 = (y1 - y2)14    return math.sqrt(t1 * t1 + t2 * t2)``
``60def distance(x1, y1, x2, y2):61    """62    l2 distance63    """6465    return math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2))``
``107def calc_distance(x0, y0, x1, y1):108    xd = x0 - x1109    yd = y0 - y1110    111    return int(sqrt(xd * xd + yd * yd))``
``48def test_different_points_1(self):49    assert math.isclose(distance(1, 1, 2, 2), math.sqrt(2))``
``9def Distance(p1,p2):10  dx = p2[0] - p1[0]11  dy = p2[1] - p1[1]12  return math.sqrt(dx*dx+dy*dy)``
``7def distance (p1,p2):8    return (math.sqrt((p2[1]-p1[1])**2 + (p2[0]-p1[0])**2))``
``37def distance(p1, p2):38    return math.sqrt(quadrance(p1, p2))``
``203def distances(points1, points2):204    # Much faster than any manual calculations205    return scipy.spatial.distance.cdist(points1, points2, metric='euclidean')``