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

# Class Osgr

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

Ordnance Survey Grid References (OSGR) coordinates on the National Grid.

Instance Methods
__init__(self, easting, northing, datum=None, name='', resolution=0) New Osgr coordinate. |
__str__(self) Default `str(self)`. |
parse(self, strOSGR, name='') Parse an OSGR reference to a similar Osgr instance. |
toLatLon(self, LatLon=None, datum=Datum(name='WGS84', ellipsoid=Ellipsoids.WGS84, transform=Tran`...`, kTM=False, eps=1e-05, **LatLon_kwds) Convert this Osgr coordinate to an (ellipsoidal) geodetic point. |
toRepr(self, GD=None, fmt='[%s]', sep=', ', **prec) Return a string representation of this Osgr coordinate. |
toStr(self, GD=None, sep='', **prec) Return this Osgr coordinate as a string. |
Inherited from `named._NamedBase`: `__repr__`, `others` Inherited from `named._Named`: `__imatmul__`, `__matmul__`, `__rmatmul__`, `attrs`, `classof`, `copy`, `dup`, `methodname`, `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`).
| falsing0 Get the `OS National Grid` falsing (EasNor2Tuple).
| iteration Get the most recent `Osgr.toLatLon` iteration number (`int`) or `None` if not available/applicable.
| latlon0 Get the `OS National Grid` origin (LatLon2Tuple).
| northing Get the northing (`meter`).
| resolution Get the OSGR resolution (`meter`, power of 10) or `0` if undefined.
| scale0 Get the `OS National Grid` central scale (`scalar`).
Inherited from `named._Named`: `classname`, `classnaming`, `name`, `named`, `named2`, `named3`, `named4`, `sizeof` Inherited from `object`: `__class__`

Method Details

### __init__ (self, easting, northing, datum=None, name='', resolution=0) (Constructor) |
New Osgr coordinate. Arguments: `easting` - Easting from the OS `National Grid` origin (`meter`). `northing` - Northing from the OS `National Grid` origin (`meter`). `datum` - Override default datum (`Datums.OSGB36`). `name` - Optional name (`str`). `resolution` - Optional resolution (`meter`), `0` for default. Raises: `OSGRError` - Invalid or negative `easting` or `northing` or `datum` not an `Datums.OSGB36` equivalent. Overrides: object.__init__

### __str__ (self) (Informal representation operator) |
Default `str(self)`. Overrides: object.__str__ (inherited documentation)

### parse (self, strOSGR, name='') |
Parse an OSGR reference 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`...`, kTM=False, eps=1e-05, **LatLon_kwds) |
Convert this Osgr coordinate to an (ellipsoidal) geodetic point. 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). `kTM` - If `True` use Karney's Krüger method from module ktm, otherwise use the Ordnance Survey formulation (`bool`). `eps` - Tolerance for OS convergence (`meter`). `LatLon_kwds` - Optional, additional `LatLon` keyword arguments, ignored if `LatLon is None`. Returns: A `LatLon` instance or if `LatLon` is `None` a LatLonDatum3Tuple`(lat, lon, datum)`. Raises: `OSGRError` - No convergence. `TypeError` - If `LatLon` is not ellipsoidal or `datum` is invalid or conversion to `datum` failed. Notes: 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. The formulation implemented here due to Thomas, Redfearn, etc. is as published by the Ordnance Survey, but is inferior to Krüger as used by e.g. Karney 2011.

### toRepr (self, GD=None, fmt='[%s]', sep=', ', **prec) |
Return a string representation of this Osgr coordinate. Arguments: `GD` - If `bool`, in- or exclude the 2-letter grid designation and get the new `prec` behavior, otherwise if `None`, default to the DEPRECATED definition `prec=5` for backward compatibility. `fmt` - Enclosing backets format (`str`). `sep` - Separator to join (`str`) or `None` to return an unjoined 2- or 3-`tuple` of `str`s. `prec` - Precison `prec=0`, the number of decimal digits (`int`) or if negative, the number of units to drop, like MGRS PRECISION. Returns: This OSGR as (`str`), `"[G:GD, E:meter, N:meter]"` or if `GD=False` `"[OSGR:easting,northing]"` or `GD=False` and `prec > 0` if `"[OSGR:easting.d,northing.d]"`. Raises: `OSGRError` - If `GD not in (None, True, False)` or if `prec < -4` and `GD=False`. `ValueError` - Invalid `prec`. Overrides: named._Named.toRepr Note: OSGR easting and northing values are truncated, not rounded.

### toStr (self, GD=None, sep='', **prec) |
Return this Osgr coordinate as a string. Arguments: `GD` - If `bool`, in- or exclude the 2-letter grid designation and get the new `prec` behavior, otherwise if `None`, default to the DEPRECATED definition `prec=5` for backward compatibility. `sep` - Separator to join (`str`) or `None` to return an unjoined 2- or 3-`tuple` of `str`s. `prec` - Precison `prec=0`, the number of decimal digits (`int`) or if negative, the number of units to drop, like MGRS PRECISION. Returns: This OSGR as (`str`), `"GD meter meter"` or if `GD=False` `"easting,northing"` or if `GD=False` and `prec > 0` `"easting.d,northing.d"` Raises: `OSGRError` - If `GD not in (None, True, False)` or if `prec < -4` and `GD=False`. `ValueError` - Invalid `prec`. Overrides: named._Named.toStr Note: OSGR easting and northing values are truncated, not rounded.

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.

### falsing0 Get the `OS National Grid` falsing (EasNor2Tuple). Get method: falsing0(self) - Get the `OS National Grid` falsing (EasNor2Tuple). 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.

### latlon0 Get the `OS National Grid` origin (LatLon2Tuple). Get method: latlon0(self) - Get the `OS National Grid` origin (LatLon2Tuple). 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.

### resolution Get the OSGR resolution (`meter`, power of 10) or `0` if undefined. Get method: resolution(self) - Get the OSGR resolution (`meter`, power of 10) or `0` if undefined. Set method: _fset_error(inst, val) - Throws an `AttributeError`, always. Delete Method: _fdel(inst) - Zap the cached/memoized `property` value.

### scale0 Get the `OS National Grid` central scale (`scalar`). Get method: scale0(self) - Get the `OS National Grid` central scale (`scalar`). Set method: _fset_error(inst, val) - Throws an `AttributeError`, always. Delete Method: _fdel(inst) - Zap the cached/memoized `property` value.