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

# Class Osgr

     object --+
              |
    bases.Named --+
                  |
        bases.Based --+
                      |
                     Osgr

Ordinance Survey Grid References (OSGR) coordinate.

Instance Methods
__init__(self, easting, northing, name=`'````'`) New OSGR National Grid Reference. |
copy(self) Copy this OSGR 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.Based`: `__repr__`, `__str__`, `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 `bases.Named`: `classname`, `classnaming`, `name` Inherited from `object`: `__class__`

Method Details

### __init__(self, easting, northing, name=`'````'`) (Constructor) |
New OSGR National Grid Reference. Parameters: `easting` - Easting from OS false easting (`meter`). `northing` - Northing from from OS false northing (`meter`). `name` - Optional name (`str`). Raises: `ValueError` - Invalid easting or northing. Overrides: object.__init__ Example:
    >>> from pygeodesy import Osgr
    >>> r = Osgr(651409, 313177)

### copy(self) |
Copy this OSGR reference. Returns: The copy (Osgr or subclass thereof). Overrides: bases.Named.copy

### 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 (sub-)class to use for the point (`LatLon`) or `None`. `datum` - Optional datum to use (`Datum`). Returns: The geodetic point (LatLon) or 3-tuple (`degrees90`, `degrees180`, 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 (`str`). Returns: This OSGR as "EN easting northing" (`str`) or as "easting,northing" if prec is non-positive. Raises: `ValueError` - Invalid prec. Overrides: bases.Based.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 (`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: bases.Based.toStr2

Property Details

### datum Get the datum (Datum). Get Method: datum(self) - Get the datum (Datum). Set Method: Read_Only(self, ignored) - Throws an `AttributeError`, always.

### easting Get the easting (`meter`). Get Method: easting(self) - Get the easting (`meter`). Set Method: Read_Only(self, ignored) - Throws an `AttributeError`, always.

### northing Get the northing (`meter`). Get Method: northing(self) - Get the northing (`meter`). Set Method: Read_Only(self, ignored) - Throws an `AttributeError`, always.