geodesy.lamberts_ellipsoidal_distance¶
Attributes¶
Functions¶
|
Calculate the shortest distance along the surface of an ellipsoid between |
Module Contents¶
- geodesy.lamberts_ellipsoidal_distance.lamberts_ellipsoidal_distance(lat1: float, lon1: float, lat2: float, lon2: float) float¶
Calculate the shortest distance along the surface of an ellipsoid between two points on the surface of Earth given longitudes and latitudes https://en.wikipedia.org/wiki/Geographical_distance#Lambert’s_formula_for_long_lines
NOTE: Uses geodesy/haversine_distance.py to compute the central angle, sigma.
Representing the Earth as an ellipsoid allows us to approximate distances between points on the surface much better than a sphere. Ellipsoidal formulas treat the Earth as an oblate ellipsoid, which means accounting for the flattening that happens at the North and South poles. Lambert’s formulae provide accuracy on the order of 10 meters over thousands of kilometers. Other methods can provide millimeter-level accuracy, but this is a simpler method to calculate long-range distances without increasing computational intensity.
- Args:
lat1, lon1: latitude and longitude of coordinate 1 lat2, lon2: latitude and longitude of coordinate 2
- Returns:
geographical distance between two points in metres
>>> lamberts_ellipsoidal_distance(100, 0, 0, 0) Traceback (most recent call last): ... ValueError: Latitude must be between -90 and 90 degrees
>>> lamberts_ellipsoidal_distance(0, 0, -100, 0) Traceback (most recent call last): ... ValueError: Latitude must be between -90 and 90 degrees
>>> lamberts_ellipsoidal_distance(0, 200, 0, 0) Traceback (most recent call last): ... ValueError: Longitude must be between -180 and 180 degrees
>>> lamberts_ellipsoidal_distance(0, 0, 0, -200) Traceback (most recent call last): ... ValueError: Longitude must be between -180 and 180 degrees
>>> from collections import namedtuple >>> point_2d = namedtuple("point_2d", "lat lon") >>> SAN_FRANCISCO = point_2d(37.774856, -122.424227) >>> YOSEMITE = point_2d(37.864742, -119.537521) >>> NEW_YORK = point_2d(40.713019, -74.012647) >>> VENICE = point_2d(45.443012, 12.313071) >>> f"{lamberts_ellipsoidal_distance(*SAN_FRANCISCO, *YOSEMITE):0,.0f} meters" '254,032 meters' >>> f"{lamberts_ellipsoidal_distance(*SAN_FRANCISCO, *NEW_YORK):0,.0f} meters" '4,133,295 meters' >>> f"{lamberts_ellipsoidal_distance(*SAN_FRANCISCO, *VENICE):0,.0f} meters" '9,719,525 meters'
- geodesy.lamberts_ellipsoidal_distance.AXIS_A = 6378137.0¶
- geodesy.lamberts_ellipsoidal_distance.AXIS_B = 6356752.314245¶
- geodesy.lamberts_ellipsoidal_distance.EQUATORIAL_RADIUS = 6378137¶