Skip to content

Commit 635e9ca

Browse files
committed
fix: update Lambert's to use corrected haversine radius for central angle
Lambert's ellipsoidal distance computes the central angle sigma by dividing the haversine distance by a radius. Previously both functions used the same equatorial radius (6378137m), so the values cancelled out. After correcting haversine to use the mean Earth radius (6371000m), Lambert's must divide by the same radius to recover the correct angle. Also update the expected doctest values to match the corrected haversine output. Fixes #11308
1 parent 9fae7d9 commit 635e9ca

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

geodesy/lamberts_ellipsoidal_distance.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from math import atan, cos, radians, sin, tan
22

3-
from .haversine_distance import haversine_distance
3+
from .haversine_distance import EARTH_RADIUS, haversine_distance
44

55
AXIS_A = 6378137.0
66
AXIS_B = 6356752.314245
@@ -39,11 +39,11 @@ def lamberts_ellipsoidal_distance(
3939
>>> NEW_YORK = point_2d(40.713019, -74.012647)
4040
>>> VENICE = point_2d(45.443012, 12.313071)
4141
>>> f"{lamberts_ellipsoidal_distance(*SAN_FRANCISCO, *YOSEMITE):0,.0f} meters"
42-
'254,351 meters'
42+
'254,032 meters'
4343
>>> f"{lamberts_ellipsoidal_distance(*SAN_FRANCISCO, *NEW_YORK):0,.0f} meters"
44-
'4,138,992 meters'
44+
'4,133,295 meters'
4545
>>> f"{lamberts_ellipsoidal_distance(*SAN_FRANCISCO, *VENICE):0,.0f} meters"
46-
'9,737,326 meters'
46+
'9,719,525 meters'
4747
"""
4848

4949
# CONSTANTS per WGS84 https://en.wikipedia.org/wiki/World_Geodetic_System
@@ -58,7 +58,7 @@ def lamberts_ellipsoidal_distance(
5858

5959
# Compute central angle between two points
6060
# using haversine theta. sigma = haversine_distance / equatorial radius
61-
sigma = haversine_distance(lat1, lon1, lat2, lon2) / EQUATORIAL_RADIUS
61+
sigma = haversine_distance(lat1, lon1, lat2, lon2) / EARTH_RADIUS
6262

6363
# Intermediate P and Q values
6464
p_value = (b_lat1 + b_lat2) / 2

0 commit comments

Comments
 (0)