Package pygeodesy :: Module osgr :: Class Osgr
[frames] | no frames]

Class Osgr

  object --+        
           |        
named._Named --+    
               |    
named._NamedBase --+
                   |
                  Osgr

Ordinance Survey Grid References (OSGR) coordinate.

Instance Methods
 
__init__(self, easting, northing, name='')
New Osgr National Grid Reference.
 
parse(self, strOSGR)
Parse a string to an Osgr instance.
 
toLatLon(self, LatLon=None, datum=Datum(name='WGS84', ellipsoid=Ellipsoids.WGS84, transform=Tran...)
Convert this OSGR coordinate to an (ellipsoidal) geodetic point.
 
toRepr(self, prec=10, fmt='[%s]', sep=', ')
Return a string representation of this OSGR coordinate.
 
toStr2(self, prec=10, fmt='[%s]', sep=', ')
DEPRECATED, use method Osgr.toRepr.
 
toStr(self, prec=10, sep=' ')
Return a string representation of this OSGR coordinate.

Inherited from named._NamedBase: __repr__, __str__, others

Inherited from named._Named: _dot_, attrs, classof, copy

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

Properties
  datum
  easting
  northing

Inherited from named._Named: classname, classnaming, name, named, named2

Inherited from object: __class__

Method Details

__init__ (self, easting, northing, name='')
(Constructor)

 

New Osgr National Grid Reference.

Arguments:
  • easting - Easting from OS false easting (meter).
  • northing - Northing from from OS false northing (meter).
  • name - Optional name (str).
Raises:
  • OSGRError - Invalid or negative easting or northing.
Overrides: object.__init__

Example:

>>> from pygeodesy import Osgr
>>> r = Osgr(651409, 313177)

parse (self, strOSGR)

 

Parse a string to an Osgr instance.

For more details, see function parseOSGR in this module osgr.

toLatLon (self, LatLon=None, datum=Datum(name='WGS84', ellipsoid=Ellipsoids.WGS84, transform=Tran...)

 

Convert this OSGR coordinate to an (ellipsoidal) geodetic point.

Note formulation implemented here due to Thomas, Redfearn, etc. is as published by OS, but is inferior to Krüger as used by e.g. Karney 2011.

Arguments:
  • LatLon - Optional ellipsoidal class to return the geodetic point (LatLon) or None.
  • datum - Optional datum to use (Datum).
Returns:
The geodetic point (LatLon) or a LatLonDatum3Tuple(lat, lon, datum) if LatLon is None.
Raises:
  • OSGRError - No convergence.
  • TypeError - If LatLon is not ellipsoidal or if datum conversion failed.

Example:

>>> from pygeodesy import ellipsoidalVincenty as eV
>>> g = Osgr(651409.903, 313177.270)
>>> p = g.toLatLon(eV.LatLon)  # 52°39′28.723″N, 001°42′57.787″E
>>> # to obtain (historical) OSGB36 lat-/longitude point
>>> p = g.toLatLon(eV.LatLon, datum=Datums.OSGB36)  # 52°39′27.253″N, 001°43′04.518″E

toRepr (self, prec=10, fmt='[%s]', sep=', ')

 

Return a string representation of this OSGR coordinate.

Arguments:
  • prec - Optional number of digits (int).
  • fmt - Optional enclosing backets format (str).
  • sep - Optional separator to join (str).
Returns:
This OSGR (str) "[G:00B, E:meter, N:meter]" or "[OSGR:meter,meter]" if prec is non-positive.
Overrides: named._Named.toRepr

toStr2 (self, prec=10, fmt='[%s]', sep=', ')

 

DEPRECATED, use method Osgr.toRepr.

Arguments:
  • prec - Optional number of digits (int).
  • fmt - Optional enclosing backets format (str).
  • sep - Optional separator to join (str).
Returns:
This OSGR (str) "[G:00B, E:meter, N:meter]" or "[OSGR:meter,meter]" if prec is non-positive.
Overrides: named._Named.toRepr

toStr (self, prec=10, sep=' ')

 

Return a string representation of this OSGR coordinate.

Note that OSGR coordinates are truncated, not rounded (unlike UTM grid references).

Arguments:
  • prec - Optional number of digits (int).
  • sep - Optional join separator (str) or None to return an unjoined tuple of strs.
Returns:
This OSGR as "EN easting northing" or as "easting,northing" if prec is non-positive (str).
Raises:
  • ValueError - Invalid prec.
Overrides: named._Named.toStr

Example:

>>> r = Osgr(651409, 313177)
>>> str(r)  # TG 5140 1317
>>> r.toStr(prec=0)  # 651409,313177


Property Details

datum

Get method:
datum(self) - Get the datum (Datum).
Set method:
immutable(inst, value) - Throws an AttributeError, always.

easting

Get method:
easting(self) - Get the easting (meter).
Set method:
immutable(inst, value) - Throws an AttributeError, always.

northing

Get method:
northing(self) - Get the northing (meter).
Set method:
immutable(inst, value) - Throws an AttributeError, always.