How to calculate 3D distance (including altitude) between two points in GeoDjango

后端 未结 3 826
别那么骄傲
别那么骄傲 2020-12-17 03:28

Prologue:

This is a question arising often in SO:

  • 3d distance calculations with GeoDjango
  • Calculating distance between two po
3条回答
  •  醉梦人生
    2020-12-17 04:14

    Using geopy, this is the easiest and perfect solution.

    https://geopy.readthedocs.io/en/stable/#geopy.distance.lonlat

    >>> from geopy.distance import distance
    >>> from geopy.point import Point
    >>> a = Point(-71.312796, 41.49008, 0)
    >>> b = Point(-81.695391, 41.499498, 0)
    >>> print(distance(a, b).miles)
    538.3904453677203
    

提交回复
热议问题