Package pygeodesy :: Module sphericalTrigonometry :: Class LatLon
[frames] | no frames]

Class LatLon

               object --+            
                        |            
               bases.Base --+        
                            |        
       bases.LatLonHeightBase --+    
                                |    
sphericalBase.LatLonSphericalBase --+
                                    |
                                   LatLon

New point on spherical model earth model.


Example:

>>> p = LatLon(52.205, 0.119)  # height=0

Instance Methods
 
alongTrackDistanceTo(self, start, end, radius=6371008.77141)
Compute the (signed) distance from the start to the closest point on the great circle path defined by a start and an end point.
 
crossingParallels(self, other, lat)
Return the pair of meridians at which a great circle defined by this and an other point crosses the given latitude.
 
crossTrackDistanceTo(self, start, end, radius=6371008.77141)
Compute the (signed) distance from this point to the great circle defined by a start and an end point.
 
destination(self, distance, bearing, radius=6371008.77141, height=None)
Locate the destination from this point after having travelled the given distance on the given initial bearing.
 
distanceTo(self, other, radius=6371008.77141)
Compute the distance from this to an other point.
 
greatCircle(self, bearing)
Compute the vector normal to great circle obtained by heading on the given initial bearing from this point.
 
initialBearingTo(self, other)
Compute the initial bearing (aka forward azimuth) from this to an other point.
 
bearingTo(self, other)
Compute the initial bearing (aka forward azimuth) from this to an other point.
 
intermediateTo(self, other, fraction, height=None)
Locate the point at given fraction between this and an other point.
 
intersection(self, bearing, start2, bearing2, height=None)
Locate the intersection of two paths each defined by a start point and an initial bearing.
 
isEnclosedBy(self, points)
Test whether this point is enclosed by the polygon defined as a list, sequence, set or tuple of points.
 
midpointTo(self, other, height=None)
Find the midpoint between this and an other point.
 
toVector3d(self)
Convert this point to a vector normal to earth's surface.

Inherited from sphericalBase.LatLonSphericalBase: finalBearingTo, maxLat, minLat, parse, rhumbBearingTo, rhumbDestination, rhumbDistanceTo, rhumbMidpointTo

Inherited from bases.LatLonHeightBase: __eq__, __init__, __ne__, __str__, bounds, copy, equals, points, to2ab, to3llh, to3xyz, toStr

Inherited from bases.Base: __repr__, classname, others, toStr2, topsub

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __subclasshook__

Properties

Inherited from sphericalBase.LatLonSphericalBase: datum, isellipsoidal, isspherical

Inherited from bases.LatLonHeightBase: height, lat, lon

Inherited from object: __class__

Method Details

alongTrackDistanceTo(self, start, end, radius=6371008.77141)

 

Compute the (signed) distance from the start to the closest point on the great circle path defined by a start and an end point.

That is, if a perpendicular is drawn from this point to the great circle path, the along-track distance is the distance from the start point to the point where the perpendicular crosses the path.

Parameters:
  • start - Start point of great circle path (LatLon).
  • end - End point of great circle path (LatLon).
  • radius - Mean earth radius (meter).
Returns:
Distance along the great circle path (positive if after the start toward the end point of the path or negative if before the start point).
Raises:
  • TypeError - The start or end point is not LatLon.

Example:

>>> p = LatLon(53.2611, -0.7972)
>>> s = LatLon(53.3206, -1.7297)
>>> e = LatLon(53.1887, 0.1334)
>>> d = p.alongTrackDistanceTo(s, e)  # 62331.58

crossingParallels(self, other, lat)

 

Return the pair of meridians at which a great circle defined by this and an other point crosses the given latitude.

Parameters:
  • other - The other point defining great circle (LatLon).
  • lat - Latitude at the crossing (degrees).
Returns:
2-Tuple (lon1, lon2) in (degrees180) or None if the great circle doesn't reach the given latitude.

crossTrackDistanceTo(self, start, end, radius=6371008.77141)

 

Compute the (signed) distance from this point to the great circle defined by a start and an end point.

Parameters:
  • start - Start point of great circle path (LatLon).
  • end - End point of great circle path (LatLon).
  • radius - Mean earth radius (meter).
Returns:
Distance to great circle (negative if to the left or positive if to the right of the path).
Raises:
  • TypeError - The start or end point is not LatLon.

Example:

>>> p = LatLon(53.2611, -0.7972)
>>> s = LatLon(53.3206, -1.7297)
>>> e = LatLon(53.1887, 0.1334)
>>> d = p.crossTrackDistanceTo(s, e)  # -307.5

destination(self, distance, bearing, radius=6371008.77141, height=None)

 

Locate the destination from this point after having travelled the given distance on the given initial bearing.

Parameters:
  • distance - Distance travelled (same units as radius).
  • bearing - Bearing from this point (compass degrees).
  • radius - Mean earth radius (meter).
  • height - Optional height at destination (meter).
Returns:
Destination point (LatLon).

Example:

>>> p1 = LatLon(51.4778, -0.0015)
>>> p2 = p1.destination(7794, 300.7)
>>> p2.toStr()  # '51.5135°N, 000.0983°W'

JS name: destinationPoint.

distanceTo(self, other, radius=6371008.77141)

 

Compute the distance from this to an other point.

Parameters:
  • other - The other point (LatLon).
  • radius - Mean earth radius (meter).
Returns:
Distance between this and the other point (in the same units as radius).
Raises:
  • TypeError - The other point is not LatLon.

Example:

>>> p1 = LatLon(52.205, 0.119)
>>> p2 = LatLon(48.857, 2.351);
>>> d = p1.distanceTo(p2)  # 404300

greatCircle(self, bearing)

 

Compute the vector normal to great circle obtained by heading on the given initial bearing from this point.

Direction of vector is such that initial bearing vector b = c × n, where n is an n-vector representing this point.

Parameters:
  • bearing - Bearing from this point (compass degrees).
Returns:
Vector representing great circle (Vector3d).

Example:

>>> p = LatLon(53.3206, -1.7297)
>>> g = p.greatCircle(96.0)
>>> g.toStr()  # (-0.794, 0.129, 0.594)

initialBearingTo(self, other)

 

Compute the initial bearing (aka forward azimuth) from this to an other point.

Parameters:
  • other - The other point (LatLon).
Returns:
Initial bearing (compass degrees).
Raises:
  • TypeError - The other point is not LatLon.

Example:

>>> p1 = LatLon(52.205, 0.119)
>>> p2 = LatLon(48.857, 2.351)
>>> b = p1.bearingTo(p2)  # 156.2

JS name: bearingTo.

bearingTo(self, other)

 

Compute the initial bearing (aka forward azimuth) from this to an other point.

Parameters:
  • other - The other point (LatLon).
Returns:
Initial bearing (compass degrees).
Raises:
  • TypeError - The other point is not LatLon.

Example:

>>> p1 = LatLon(52.205, 0.119)
>>> p2 = LatLon(48.857, 2.351)
>>> b = p1.bearingTo(p2)  # 156.2

JS name: bearingTo.

intermediateTo(self, other, fraction, height=None)

 

Locate the point at given fraction between this and an other point.

Parameters:
  • other - The other point (LatLon).
  • fraction - Fraction between both points (float, 0.0 = this point, 1.0 = the other point).
  • height - Optional height, overriding the fractional height (meter).
Returns:
Intermediate point (LatLon).
Raises:
  • TypeError - The other point is not LatLon.

Example:

>>> p1 = LatLon(52.205, 0.119)
>>> p2 = LatLon(48.857, 2.351)
>>> p = p1.intermediateTo(p2, 0.25)  # 51.3721°N, 000.7073°E

JS name: intermediatePointTo.

intersection(self, bearing, start2, bearing2, height=None)

 

Locate the intersection of two paths each defined by a start point and an initial bearing.

Parameters:
  • bearing - Initial bearing from this point (compass degrees).
  • start2 - Start point of second path (LatLon).
  • bearing2 - Initial bearing from start2 (compass degrees).
  • height - Optional height for intersection point, overriding the mean height (meter).
Returns:
Intersection point (LatLon).
Raises:
  • TypeError - Point start2 is not a LatLon.
  • ValueError - Intersection is ambiguous or infinite or the paths are parallel or coincide.

Example:

>>> p = LatLon(51.8853, 0.2545)
>>> s = LatLon(49.0034, 2.5735)
>>> i = p.intersection(108.547, s, 32.435)  # '50.9078°N, 004.5084°E'

isEnclosedBy(self, points)

 

Test whether this point is enclosed by the polygon defined as a list, sequence, set or tuple of points.

Parameters:
  • points - The points defining the polygon (LatLon[]).
Returns:
True if the polygon encloses this point (bool).
Raises:
  • ValueError - Too few points or non-convex polygon.
  • TypeError - Some points are not LatLon.

Example:

>>> b = LatLon(45,1), LatLon(45,2), LatLon(46,2), LatLon(46,1)
>>> p = LatLon(45,1, 1.1)
>>> inside = p.isEnclosedBy(b)  # True

midpointTo(self, other, height=None)

 

Find the midpoint between this and an other point.

Parameters:
  • other - The other point (LatLon).
  • height - Optional height for midpoint, overriding the mean height (meter).
Returns:
Midpoint (LatLon).
Raises:
  • TypeError - The other point is not LatLon.

Example:

>>> p1 = LatLon(52.205, 0.119)
>>> p2 = LatLon(48.857, 2.351)
>>> m = p1.midpointTo(p2)  # '50.5363°N, 001.2746°E'

toVector3d(self)

 

Convert this point to a vector normal to earth's surface.

Returns:
Vector representing this point (Vector3d).