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

Class Osgr

object --+    
         |    
bases.Base --+
             |
            Osgr

Ordinance Survey Grid References (OSGR) coordinate.

Instance Methods
 
__init__(self, easting, northing)
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.
 
toStr(self, prec=10, sep=' ')
Return a string representation of this OSGR coordinate.
 
toStr2(self, prec=10, fmt='[%s]', sep=', ')
Return a string representation of this OSGR coordinate.

Inherited from bases.Base: __repr__, __str__, classname, classof, others

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

Properties
  datum
Get the datum (Datum).
  easting
Get the easting (meter).
  northing
Get the northing (meter).

Inherited from object: __class__

Method Details

__init__(self, easting, northing)
(Constructor)

 

New OSGR National Grid Reference.

Parameters:
  • easting - Easting from OS false easting (meter).
  • northing - Northing from from OS false northing (meter).
Raises:
  • ValueError - Invalid 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.}

Parameters:
  • LatLon - Optional ellipsoidal LatLon class to use for the point (LatLon).
  • datum - Optional datum to use (Datum).
Returns:
The geodetic point (LatLon) or 3-tuple (lat, lon, datum) if LatLon is None.
Raises:
  • 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

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).

Parameters:
  • prec - Optional number of digits (int).
  • sep - Optional separator to join (string).
Returns:
This OSGR as "EN easting northing" (string) or as "easting,northing" if prec is non-positive.
Raises:
  • ValueError - Invalid prec.
Overrides: bases.Base.toStr

Example:

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

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

 

Return a string representation of this OSGR coordinate.

Parameters:
  • prec - Optional number of digits (int).
  • fmt - Optional enclosing backets format (string).
  • sep - Optional separator to join (string).
Returns:
This OSGR as "[G:00B, E:meter, N:meter]" or as "OSGR:meter,meter" if prec is non-positive (string).
Overrides: bases.Base.toStr2

Property Details

datum

Get the datum (Datum).

Get Method:
datum(self) - Get the datum (Datum).

easting

Get the easting (meter).

Get Method:
easting(self) - Get the easting (meter).

northing

Get the northing (meter).

Get Method:
northing(self) - Get the northing (meter).