Skip to content

Commit 0212c42

Browse files
Update lamberts_ellipsoidal_distance.py
1 parent 35c61fc commit 0212c42

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

geodesy/lamberts_ellipsoidal_distance.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,24 @@ def lamberts_ellipsoidal_distance(
1111
lat1: float, lon1: float, lat2: float, lon2: float
1212
) -> float:
1313
"""
14+
Calculate the shortest distance along the surface of an ellipsoid between
15+
two points on the surface of earth given longitudes and latitudes
16+
https://en.wikipedia.org/wiki/Geographical_distance#Lambert's_formula_for_long_lines
17+
18+
NOTE: This algorithm uses geodesy/haversine_distance.py to compute central angle,
19+
sigma
20+
21+
Representing the earth as an ellipsoid allows us to approximate distances between
22+
points on the surface much better than a sphere. Ellipsoidal formulas treat the
23+
Earth as an oblate ellipsoid which means accounting for the flattening that happens
24+
at the North and South poles. Lambert's formulae provide accuracy on the order of
25+
10 meteres over thousands of kilometeres. Other methods can provide
26+
millimeter-level accuracy but this is a simpler method to calculate long range
27+
distances without increasing computational intensity.
1428
1529
Args:
1630
lat1, lon1: latitude and longitude of coordinate 1
1731
lat2, lon2: latitude and longitude of coordinate 2
18-
1932
Returns:
2033
geographical distance between two points in metres
2134
@@ -24,11 +37,21 @@ def lamberts_ellipsoidal_distance(
2437
...
2538
ValueError: Latitude must be between -90 and 90 degrees
2639
40+
>>> lamberts_ellipsoidal_distance(0, 0, -100, 0)
41+
Traceback (most recent call last):
42+
...
43+
ValueError: Latitude must be between -90 and 90 degrees
44+
2745
>>> lamberts_ellipsoidal_distance(0, 200, 0, 0)
2846
Traceback (most recent call last):
2947
...
3048
ValueError: Longitude must be between -180 and 180 degrees
3149
50+
>>> lamberts_ellipsoidal_distance(0, 0, 0, -200)
51+
Traceback (most recent call last):
52+
...
53+
ValueError: Longitude must be between -180 and 180 degrees
54+
3255
>>> from collections import namedtuple
3356
>>> point_2d = namedtuple("point_2d", "lat lon")
3457
>>> SAN_FRANCISCO = point_2d(37.774856, -122.424227)

0 commit comments

Comments
 (0)