Package pygeodesy :: Module wgrs |
[frames] | no frames]

# Module wgrs

Classes Georef and WGRSError and several functions to encode, decode and inspect World Geographic Reference System (WGRS) references.

Transcribed from Charles Karney's C++ class Georef, but with modified `precision` and extended with `height` and `radius`. See also World Geographic Reference System.

Version: 21.01.23

Classes
| WGRSError World Geographic Reference System (WGRS) encode, decode or other Georef issue.
| Georef Georef class, a named `str`.

Functions
decode3(georef, center=True) Decode a `georef` to lat-, longitude and precision. |
decode5(georef, center=True) Decode a `georef` to lat-, longitude, precision, height and radius. |
encode(lat, lon, precision=3, height=None, radius=None) Encode a lat-/longitude as a `georef` of the given precision. |
precision(res) Determine the Georef precision to meet a required (geographic) resolution. |
resolution(prec) Determine the (geographic) resolution of a given Georef precision. |

Variables
| __all__ = `_ALL_LAZY.wgrs`

Function Details

### decode3 (georef, center=True) |
Decode a `georef` to lat-, longitude and precision. Arguments: `georef` - To be decoded (Georef or `str`). `center` - If `True` the center, otherwise the south-west, lower-left corner (`bool`). Returns: A LatLonPrec3Tuple`(lat, lon, precision)`. Raises: `WGRSError` - Invalid `georef`, INValid, non-alphanumeric or odd length `georef`.

### decode5 (georef, center=True) |
Decode a `georef` to lat-, longitude, precision, height and radius. Arguments: `georef` - To be decoded (Georef or `str`). `center` - If `True` the center, otherwise the south-west, lower-left corner (`bool`). Returns: A LatLonPrec5Tuple`(lat, lon, precision, height, radius)` where `height` and/or `radius` are `None` if missing. Raises: `WGRSError` - Invalid `georef`, INValid, non-alphanumeric or odd length `georef`.

### encode (lat, lon, precision=3, height=None, radius=None) |
Encode a lat-/longitude as a `georef` of the given precision. Arguments: `lat` - Latitude (`degrees`). `lon` - Longitude (`degrees`). `precision` - Optional, the desired `georef` resolution and length (`int` 0..11). `height` - Optional, height in `meter`, see Designation of area. `radius` - Optional, radius in `meter`, see Designation of area. Returns: The `georef` (`str`). Raises: `RangeError` - Invalid `lat` or `lon`. `WGRSError` - Invalid `precision`, `height` or `radius`. Note: The `precision` value differs from Georef. The `georef` length is 2 * (precision + 1) and the `georef` resolution is 15° for `precision` 0, 1° for 1, 1′ for 2, 0.1′ for 3, 0.01′ for 4, ... 10**(2 - precision).

### precision (res) |
Determine the Georef precision to meet a required (geographic) resolution. Arguments: `res` - The required resolution (`degrees`). Returns: The Georef precision (`int` 0..11). Raises: `ValueError` - Invalid `res`. See Also: Function wgrs.encode for more `precision` details.

### resolution (prec) |
Determine the (geographic) resolution of a given Georef precision. Arguments: `prec` - The given precision (`int`). Returns: The (geographic) resolution (`degrees`). Raises: `ValueError` - Invalid `prec`. See Also: Function wgrs.encode for more `precision` details.