RCAIDE.Library.Methods.Geodesics.Geodesics

Geodesics#

Classes

Constants()

Constants describing the WGS84 ellipsoid

Distance(*args, **kwargs)

Modified to remve unit conversions to stay with RCAIDE conventions - Oct.

Geodesic(a, f)

Solve geodesic problems

GeodesicCapability()

Capability constants shared between Geodesic and GeodesicLine.

GeodesicDistance

alias of Geodesic_Calculate

Geodesic_Calculate(*args, **kwargs)

Calculate the geodesic distance between points.

Math()

Additional math routines for GeographicLib.

distance

alias of Geodesic_Calculate

class Math[source]#

Bases: object

Additional math routines for GeographicLib.

static sq(x)[source]#

Square a number

static cbrt(x)[source]#

Real cube root of a number

static norm(x, y)[source]#

Private: Normalize a two-vector.

static sum(u, v)[source]#

Error free transformation of a sum.

static polyval(N, p, s, x)[source]#

Evaluate a polynomial.

static AngRound(x)[source]#

Private: Round an angle so that small values underflow to zero.

static remainder(x, y)[source]#

remainder of x/y in the range [-y/2, y/2].

static AngNormalize(x)[source]#

reduce angle to [-180,180]

static LatFix(x)[source]#

replace angles outside [-90,90] by NaN

static AngDiff(x, y)[source]#

compute y - x and reduce to [-180,180] accurately

static sincosd(x)[source]#

Compute sine and cosine of x in degrees.

static sincosde(x, t)[source]#

Compute sine and cosine of (x + t) in degrees with x in [-180, 180]

class GeodesicCapability[source]#

Bases: object

Capability constants shared between Geodesic and GeodesicLine.

CAP_NONE = 0#
CAP_C1 = 1#
CAP_C1p = 2#
CAP_C2 = 4#
CAP_C3 = 8#
CAP_C4 = 16#
CAP_ALL = 31#
CAP_MASK = 31#
OUT_ALL = 32640#
OUT_MASK = 65408#
EMPTY = 0#
LATITUDE = 128#
LONGITUDE = 264#
AZIMUTH = 512#
DISTANCE = 1025#
STANDARD = 1929#
DISTANCE_IN = 2051#
REDUCEDLENGTH = 4101#
GEODESICSCALE = 8197#
AREA = 16400#
LONG_UNROLL = 32768#
ALL = 32671#
class Constants[source]#

Bases: object

Constants describing the WGS84 ellipsoid

WGS84_a = 6378137.0#

the equatorial radius in meters of the WGS84 ellipsoid in meters

WGS84_f = 0.0033528106647474805#

the flattening of the WGS84 ellipsoid, 1/298.257223563

class Geodesic(a, f)[source]#

Bases: object

Solve geodesic problems

GEOGRAPHICLIB_GEODESIC_ORDER = 6#
nA1_ = 6#
nC1_ = 6#
nC1p_ = 6#
nA2_ = 6#
nC2_ = 6#
nA3_ = 6#
nA3x_ = 6#
nC3_ = 6#
nC3x_ = 15#
nC4_ = 6#
nC4x_ = 21#
maxit1_ = 20#
maxit2_ = 83#
tiny_ = 1.4916681462400413e-154#
tol0_ = 2.220446049250313e-16#
tol1_ = 4.440892098500626e-14#
tol2_ = 1.4901161193847656e-08#
tolb_ = 3.308722450212111e-24#
xthresh_ = 1.4901161193847656e-05#
CAP_NONE = 0#
CAP_C1 = 1#
CAP_C1p = 2#
CAP_C2 = 4#
CAP_C3 = 8#
CAP_C4 = 16#
CAP_ALL = 31#
CAP_MASK = 31#
OUT_ALL = 32640#
OUT_MASK = 65408#
__init__(a, f)[source]#

Construct a Geodesic object

Parameters:
  • a – the equatorial radius of the ellipsoid in meters

  • f – the flattening of the ellipsoid

An exception is thrown if a or the polar semi-axis b = a (1 - f) is not a finite positive quantity.

a#

The equatorial radius in meters (readonly)

f#

The flattening (readonly)

Inverse(lat1, lon1, lat2, lon2, outmask=1929)[source]#

Solve the inverse geodesic problem

Parameters:
  • lat1 – latitude of the first point in degrees

  • lon1 – longitude of the first point in degrees

  • lat2 – latitude of the second point in degrees

  • lon2 – longitude of the second point in degrees

  • outmask – the output mask

Returns:

a dict

Compute geodesic between (lat1, lon1) and (lat2, lon2). The default value of outmask is STANDARD, i.e., the lat1, lon1, azi1, lat2, lon2, azi2, s12, a12 entries are returned.

EMPTY = 0#

No capabilities, no output.

LATITUDE = 128#

Calculate latitude lat2.

LONGITUDE = 264#

Calculate longitude lon2.

AZIMUTH = 512#

Calculate azimuths azi1 and azi2.

DISTANCE = 1025#

Calculate distance s12.

STANDARD = 1929#

All of the above.

DISTANCE_IN = 2051#

Allow distance s12 to be used as input in the direct geodesic problem.

REDUCEDLENGTH = 4101#

Calculate reduced length m12.

GEODESICSCALE = 8197#

Calculate geodesic scales M12 and M21.

AREA = 16400#

Calculate area S12.

ALL = 32671#

All of the above.

LONG_UNROLL = 32768#

Unroll longitudes, rather than reducing them to the range [-180d,180d].

WGS84 = <RCAIDE.Library.Methods.Geodesics.Geodesics.Geodesic object>#
class Distance(*args, **kwargs)[source]#

Bases: object

Modified to remve unit conversions to stay with RCAIDE conventions - Oct. 2024 Base class for other distance algorithms. Represents a distance.

Can be used for units conversion:

>>> from geopy.distance import Distance
>>> Distance(miles=10).km
16.09344

Distance instances have all distance properties from geopy.units, e.g.: km, m, meters, miles and so on.

Distance instances are immutable.

They support comparison:

>>> from geopy.distance import Distance
>>> Distance(kilometers=2) == Distance(meters=2000)
True
>>> Distance(kilometers=2) > Distance(miles=1)
True

String representation:

>>> from geopy.distance import Distance
>>> repr(Distance(kilometers=2))
'Distance(2.0)'
>>> str(Distance(kilometers=2))
'2.0 km'
>>> repr(Distance(miles=2))
'Distance(3.218688)'
>>> str(Distance(miles=2))
'3.218688 km'

Arithmetics:

>>> from geopy.distance import Distance
>>> -Distance(miles=2)
Distance(-3.218688)
>>> Distance(miles=2) + Distance(kilometers=1)
Distance(4.218688)
>>> Distance(miles=2) - Distance(kilometers=1)
Distance(2.218688)
>>> Distance(kilometers=6) * 5
Distance(30.0)
>>> Distance(kilometers=6) / 5
Distance(1.2)
__init__(*args, **kwargs)[source]#

There are 3 ways to create a distance:

  • From kilometers:

    >>> from geopy.distance import Distance
    >>> Distance(1.42)
    Distance(1.42)
    
  • From points (for non-abstract distances only), calculated as a sum of distances between all points:

    >>> from geopy.distance import geodesic
    >>> geodesic((40, 160), (40.1, 160.1))
    Distance(14.003702498106215)
    >>> geodesic((40, 160), (40.1, 160.1), (40.2, 160.2))
    Distance(27.999954644813478)
    
measure(a, b)[source]#
destination(point, bearing, distance=None)[source]#

Calculate destination point using a starting point, bearing and a distance. This method works for non-abstract distances only.

Example: a point 10 miles east from (34, 148):

>>> import geopy.distance
>>> geopy.distance.distance(miles=10).destination((34, 148), bearing=90)
Point(33.99987666492774, 148.17419994321995, 0.0)
Parameters:
  • point (geopy.point.Point, list or tuple of (latitude, longitude), or string as "%(latitude)s, %(longitude)s".) – Starting point.

  • bearing (float) – Bearing in degrees: 0 – North, 90 – East, 180 – South, 270 or -90 – West.

  • distance (Distance) –

    Distance, can be used to override this instance:

    >>> from geopy.distance import distance, Distance
    >>> distance(miles=10).destination((34, 148), bearing=90, \distance=Distance(100))
    Point(33.995238229104764, 149.08238904409637, 0.0)
    

Return type:

geopy.point.Point

property kilometers#
property km#
class Geodesic_Calculate(*args, **kwargs)[source]#

Bases: Distance

Calculate the geodesic distance between points.

Set which ellipsoidal model of the earth to use by specifying an ellipsoid keyword argument. The default is ‘WGS-84’, which is the most globally accurate model. If ellipsoid is a string, it is looked up in the ELLIPSOIDS dictionary to obtain the major and minor semiaxes and the flattening. Otherwise, it should be a tuple with those values. See the comments above the ELLIPSOIDS dictionary for more information.

Example:

>>> from geopy.distance import geodesic
>>> newport_ri = (41.49008, -71.312796)
>>> cleveland_oh = (41.499498, -81.695391)
>>> print(geodesic(newport_ri, cleveland_oh).miles)
538.390445368
__init__(*args, **kwargs)[source]#

There are 3 ways to create a distance:

  • From kilometers:

    >>> from geopy.distance import Distance
    >>> Distance(1.42)
    Distance(1.42)
    
  • From points (for non-abstract distances only), calculated as a sum of distances between all points:

    >>> from geopy.distance import geodesic
    >>> geodesic((40, 160), (40.1, 160.1))
    Distance(14.003702498106215)
    >>> geodesic((40, 160), (40.1, 160.1), (40.2, 160.2))
    Distance(27.999954644813478)
    
set_ellipsoid(ellipsoid)[source]#
measure(a, b)[source]#
GeodesicDistance#

alias of Geodesic_Calculate

distance#

alias of Geodesic_Calculate