Package pygeodesy :: Module bases :: Class LatLonHeightBase
[frames] | no frames]

Class LatLonHeightBase

object --+        
         |        
     Named --+    
             |    
         Based --+
                 |
                LatLonHeightBase
Known Subclasses:

(INTERNAL) Base class for LatLon points on spherical or ellipsiodal earth models.

Instance Methods
 
__eq__(self, other)
 
__init__(self, lat, lon, height=0, name='')
New LatLon.
 
__ne__(self, other)
 
__str__(self)
str(x)
 
antipode(self, height=None)
Return the antipode, the point diametrically opposite to this point.
 
bounds(self, wide, high, radius=6371008.77141)
Return the SE and NW lat-/longitude of a great circle bounding box centered at this location.
 
compassAngle(self, other)
Return the angle from North for the direction vector between this and an other point.
 
copy(self)
Copy this point.
 
equals(self, other, eps=None)
Compare this point with an other point.
 
equals3(self, other, eps=None)
Compare this point with an other point.
 
isantipode(self, other, eps=2.22044604925e-16)
Check whether this and an other point are antipodal, on diametrically opposite sides of the earth.
 
latlon_(self, ndigits=0)
Return the latitude and longitude, rounded.
 
points(self, points, closed=True)
Check a polygon given as list, set or tuple of points.
 
to2ab(self)
Return this point's lat-/longitude in radians.
 
to3llh(self)
Return this point's lat-, longitude and height.
 
to3xyz(self)
Convert this (geodetic) point to (n-)vector (normal to the earth's surface) x/y/z components, ignoring the height.
 
toStr(self, form='dms', prec=None, m='m', sep=', ')
Convert this point to a "lat, lon [+/-height]" string, formatted in the given form.

Inherited from Based: __repr__, classof, others, toStr2

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

Properties
  height
Get the height (meter).
  lat
Get the latitude (degrees).
  latlon
Get the latitude and longitude (2-tuple of degrees).
  lon
Get the longitude (degrees).

Inherited from Named: classname, classnaming, name

Inherited from object: __class__

Method Details

__init__(self, lat, lon, height=0, name='')
(Constructor)

 

New LatLon.

Parameters:
  • lat - Latitude (degrees or DMS string with N or S suffix).
  • lon - Longitude (degrees or DMS string with E or W suffix).
  • height - Optional height (meter above or below the earth surface).
  • name - Optional name (string).
Returns:
New instance (LatLon).
Raises:
  • RangeError - Value of lat or lon outside the valid range and rangerrrors set to True.
  • ValueError - Invalid lat or lon.
Overrides: object.__init__

Example:

>>> p = LatLon(50.06632, -5.71475)
>>> q = LatLon('50°03′59″N', """005°42'53"W""")

__str__(self)
(Informal representation operator)

 

str(x)

Overrides: object.__str__
(inherited documentation)

antipode(self, height=None)

 

Return the antipode, the point diametrically opposite to this point.

Parameters:
  • height - Optional height of the antipode, height of this point otherwise (meter).
Returns:
The antipodal point (LatLon).

bounds(self, wide, high, radius=6371008.77141)

 

Return the SE and NW lat-/longitude of a great circle bounding box centered at this location.

Parameters:
  • wide - Longitudinal box width (meter, like radius).
  • high - Latitudinal box height (meter, like radius).
  • radius - Optional, mean earth radius (meter).
Returns:
2-Tuple (LatLonSW, LatLonNE) of (LatLons).

compassAngle(self, other)

 

Return the angle from North for the direction vector between this and an other point.

Suitable only for short, non-near-polar vectors up to a few hundred Km or Miles. Use LatLon methods initialBearingTo or forward azimuth for larger distances.

Parameters:
  • other - The other point (LatLon).
Returns:
Angle from North (degrees360).
Raises:
  • TypeError - The other point is not LatLon.

Note: Courtesy Martin Schultz.

See Also: Local, Flat Earth.

copy(self)

 

Copy this point.

Returns:
The copy (LatLon or subclass thereof).
Overrides: Named.copy

equals(self, other, eps=None)

 

Compare this point with an other point.

Parameters:
  • other - The other point (LatLon).
  • eps - Tolerance for equality (degrees).
Returns:
True if both points are identical, ignoring height (bool).
Raises:
  • TypeError - The other point is not LatLon.

See Also: Method equals3.

Example:

>>> p = LatLon(52.205, 0.119)
>>> q = LatLon(52.205, 0.119)
>>> e = p.equals(q)  # True

equals3(self, other, eps=None)

 

Compare this point with an other point.

Parameters:
  • other - The other point (LatLon).
  • eps - Tolerance for equality (degrees).
Returns:
True if both points are identical, including height (bool).
Raises:
  • TypeError - The other point is not LatLon.

See Also: Method equals.

Example:

>>> p = LatLon(52.205, 0.119, 42)
>>> q = LatLon(52.205, 0.119)
>>> e = p.equals3(q)  # False

isantipode(self, other, eps=2.22044604925e-16)

 

Check whether this and an other point are antipodal, on diametrically opposite sides of the earth.

Parameters:
  • other - The other point (LatLon).
  • eps - Tolerance for near-equality (degrees).
Returns:
True if points are antipodal within the given tolerance, False otherwise.

latlon_(self, ndigits=0)

 

Return the latitude and longitude, rounded.

Parameters:
  • ndigits - Number of decimal digits (int).
Returns:
2-Tuple (lat, lon) in (degrees, degrees), rounded away from zero to ndigits.

See Also: Built-in function round.

points(self, points, closed=True)

 

Check a polygon given as list, set or tuple of points.

Parameters:
  • points - The points of the polygon (LatLon[])
  • closed - Optionally, treat polygon as closed (bool).
Returns:
2-Tuple (number, sequence) of points (int, sequence).
Raises:
  • TypeError - Some points are not LatLon.
  • ValueError - Insufficient number of points.

to2ab(self)

 

Return this point's lat-/longitude in radians.

Returns:
2-Tuple (lat, lon) in (radians, radians).

to3llh(self)

 

Return this point's lat-, longitude and height.

Returns:
3-Tuple (lat, lon, h) in (degrees, degrees, meter).

to3xyz(self)

 

Convert this (geodetic) point to (n-)vector (normal to the earth's surface) x/y/z components, ignoring the height.

Returns:
3-Tuple (x, y, z) in (units, NOT meter).

toStr(self, form='dms', prec=None, m='m', sep=', ')

 

Convert this point to a "lat, lon [+/-height]" string, formatted in the given form.

Parameters:
  • form - Optional format, F_D, F_DM, F_DMS for deg°, deg°min′, deg°min′sec″ (string).
  • prec - Optional number of decimal digits (0..8 or None).
  • m - Optional unit of the height (string).
  • sep - Optional separator to join (string).
Returns:
Point in the specified form (string).
Overrides: Based.toStr

Example:

>>> LatLon(51.4778, -0.0016).toStr()  # 51°28′40″N, 000°00′06″W
>>> LatLon(51.4778, -0.0016).toStr(F_D)  # 51.4778°N, 000.0016°W
>>> LatLon(51.4778, -0.0016, 42).toStr()  # 51°28′40″N, 000°00′06″W, +42.00m


Property Details

height

Get the height (meter).

Get Method:
height(self) - Get the height (meter).
Set Method:
height(self, height) - Set the height.

lat

Get the latitude (degrees).

Get Method:
lat(self) - Get the latitude (degrees).
Set Method:
lat(self, lat) - Set the latitude.

latlon

Get the latitude and longitude (2-tuple of degrees).

Get Method:
latlon(self) - Get the latitude and longitude (2-tuple of degrees).
Set Method:
latlon(self, latlonh) - Set the lat- and longitude and optionally the height.

lon

Get the longitude (degrees).

Get Method:
lon(self) - Get the longitude (degrees).
Set Method:
lon(self, lon) - Set the longitude.