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, datum=None, name='') New Osgr National Grid Reference. |
parse(self, strOSGR, name='') Parse a string to a similar 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. |
toStr(self, prec=10, sep=' ') Return a string representation of this OSGR coordinate. |
Inherited from `named._NamedBase`: `__repr__`, `__str__`, `others` Inherited from `named._Named`: `__imatmul__`, `__matmul__`, `__rmatmul__`, `attrs`, `classof`, `copy`, `dup`, `rename`, `toStr2` 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`).
| iteration Get the most recent `Osgr.toLatLon` iteration number (`int`) or `None` if not available/applicable.
| northing Get the northing (`meter`).
Inherited from `named._Named`: `classname`, `classnaming`, `name`, `named`, `named2`, `named3`, `named4` Inherited from `object`: `__class__`

Method Details

### __init__ (self, easting, northing, datum=None, name='') (Constructor) |
New Osgr National Grid Reference. Arguments: `easting` - Easting from OS false easting (`meter`). `northing` - Northing from from OS false northing (`meter`). `datum` - Default datum (`Datums.OSGB36`). `name` - Optional name (`str`). Raises: `OSGRError` - Invalid or negative `easting` or `northing` or `datum` not `Datums.OSBG36`. Overrides: object.__init__ Example:
    >>> from pygeodesy import Osgr
    >>> r = Osgr(651409, 313177)

### parse (self, strOSGR, name='') |
Parse a string to a similar Osgr instance. Arguments: `strOSGR` - The OSGR reference (`str`), see function parseOSGR. `name` - Optional instance name (`str`), overriding this name. Returns: The similar instance (Osgr) Raises: `OSGRError` - Invalid `strOSGR`.

### toLatLon (self, LatLon=None, datum=Datum(name='WGS84', ellipsoid=Ellipsoids.WGS84, transform=Tran`...`) |
Convert this OSGR coordinate to an (ellipsoidal) geodetic point. While OS grid references are based on the OSGB36 datum, the Ordnance Survey have deprecated the use of OSGB36 for lat-/longitude coordinates (in favour of WGS84). Hence, this method returns WGS84 by default with OSGB36 as an option, see. 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 convert to (Datum, Ellipsoid, Ellipsoid2, Ellipsoid2 or a_f2Tuple). 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 `datum` is invalid or 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` - Number of digits (`int`). `fmt` - Enclosing backets format (`str`). `sep` - 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 separator to join (`str`) or `None` to return an unjoined `tuple` of `str`s. 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 the datum (Datum). Get method: datum(self) - Get the datum (Datum). Set method: _fset_error(inst, val) - Throws an `AttributeError`, always. Delete Method: _fdel(inst) - Zap the cached/memoized `property` value.

### easting Get the easting (`meter`). Get method: easting(self) - Get the easting (`meter`). Set method: _fset_error(inst, val) - Throws an `AttributeError`, always. Delete Method: _fdel(inst) - Zap the cached/memoized `property` value.

### iteration Get the most recent `Osgr.toLatLon` iteration number (`int`) or `None` if not available/applicable. Get method: iteration(self) - Get the most recent `Osgr.toLatLon` iteration number (`int`) or `None` if not available/applicable. Set method: _fset_error(inst, val) - Throws an `AttributeError`, always. Delete Method: _fdel(inst) - Zap the cached/memoized `property` value.

### northing Get the northing (`meter`). Get method: northing(self) - Get the northing (`meter`). Set method: _fset_error(inst, val) - Throws an `AttributeError`, always. Delete Method: _fdel(inst) - Zap the cached/memoized `property` value.