clouddrift.sphere.position_from_distance_and_bearing#
- clouddrift.sphere.position_from_distance_and_bearing(lon: float, lat: float, distance: float, bearing: float) tuple[float, float] [source]#
Return elementwise new position in degrees from arrays of latitude and longitude in degrees, distance in meters, and bearing in radians, based on the spherical law of cosines.
The formula is:
φ2 = asin( sin φ1 ⋅ cos δ + cos φ1 ⋅ sin δ ⋅ cos θ ) λ2 = λ1 + atan2( sin θ ⋅ sin δ ⋅ cos φ1, cos δ − sin φ1 ⋅ sin φ2 )
where (φ, λ) is (lat, lon) and θ is bearing, all in radians. Bearing is defined as zero toward East and positive counterclockwise.
Parameters#
- lonfloat
Longitude of the first set of points, in degrees
- latfloat
Latitude of the first set of points, in degrees
- distancearray_like
Distance in meters
- bearingarray_like
Bearing angles in radians
Returns#
- lon2array_like
Latitudes of the second set of points, in degrees, in the range [-90, 90]
- lat2array_like
Longitudes of the second set of points, in degrees, in the range [-180, 180]
Examples#
Calculate the position of one degree longitude distance on the equator:
>>> position_from_distance_and_bearing(0, 0, 111318.84502145034, 0) (1.0, 0.0)
Calculate the position of one degree latitude distance from 45 degrees North latitude:
>>> position_from_distance_and_bearing(0, 45, 111318.84502145034, np.pi / 2) (8.81429402840006e-17, 45.99999999999999)