Package pygeodesy :: Module mgrs :: Class Mgrs |
[frames] | no frames]

# Class Mgrs

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

Military Grid Reference System (MGRS/NATO) references, with method to convert to UTM coordinates.

Instance Methods
__init__(self, zone, en100k, easting, northing, band=`'````'`, datum=Datum(name='WGS84', ellipsoid=Ellipsoids.WGS84, transform=Tran`...`, name=`'````'`) New MGRS grid reference. |
copy(self) Copy this MGRS reference. |
parse(self, strMGRS) Parse a string to a MGRS grid reference. |
toStr(self, prec=10, sep=`'``` `'`) Return a string representation of this MGRS grid reference. |
toStr2(self, prec=10, fmt=`'``[%s]``'`, sep=`'``,` `'`) Return a string representation of this MGRS grid reference. |
toUtm(self, Utm=<class 'pygeodesy.utm.Utm'>) Convert this MGRS grid reference to a UTM coordinate. |
Inherited from `bases.Based`: `__repr__`, `__str__`, `classof`, `others` Inherited from `object`: `__delattr__`, `__format__`, `__getattribute__`, `__hash__`, `__new__`, `__reduce__`, `__reduce_ex__`, `__setattr__`, `__sizeof__`, `__subclasshook__`

Properties
| band Get the latitudinal band (A..Z `str`).
| bandLatitude Get the band latitude (`degrees90` or `None`).
| datum Get the datum (Datum).
| en100k Get the 2-character grid (EN digraph `str`).
| easting Gets the easting (`meter`).
| northing Get the northing (`meter`).
| zone Get the longitudal zone (1..60 `int`).
Inherited from `bases.Named`: `classname`, `classnaming`, `name` Inherited from `object`: `__class__`

Method Details

### __init__(self, zone, en100k, easting, northing, band=`'````'`, datum=Datum(name='WGS84', ellipsoid=Ellipsoids.WGS84, transform=Tran`...`, name=`'````'`) (Constructor) |
New MGRS grid reference. Parameters: `zone` - 6° longitudinal zone (`int`), 1..60 covering 180°W..180°E. `en100k` - Two-letter EN digraph (`str`), 100 km grid square. `easting` - Easting (`meter`), within 100 km grid square. `northing` - Northing (`meter`), within 100 km grid square. `band` - Optional 8° latitudinal band (`str`), C..X covering 80°S..84°N. `datum` - Optional this reference's datum (Datum). `name` - Optional name (`str`). Raises: `ValueError` - Invalid MGRS grid reference, zone, en100k or band. Overrides: object.__init__ Example:
    >>> from mgrs import Mgrs
    >>> m = Mgrs('31U', 'DQ', 48251, 11932)  # 31U DQ 48251 11932

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

### parse(self, strMGRS) |
Parse a string to a MGRS grid reference. Parameters: `strMGRS` - MGRS grid reference (`str`). Returns: MGRS reference (Mgrs). Raises: `ValueError` - Invalid strMGRS. See Also: Function parseMGRS in this module mgrs.

### toStr(self, prec=10, sep=`'``` `'`) |
Return a string representation of this MGRS grid reference. Note that MGRS grid references are truncated, not rounded (unlike UTM coordinates). Parameters: `prec` - Optional number of digits (`int`), 4:km, 10:m. `sep` - Optional separator to join (`str`). Returns: This Mgrs as "00B EN easting northing" (`str`). Raises: `ValueError` - Invalid prec. Overrides: bases.Based.toStr Example:
    >>> m = Mgrs(31, 'DQ', 48251, 11932, band='U')
    >>> m.toStr()  # '31U DQ 48251 11932'

### toStr2(self, prec=10, fmt=`'``[%s]``'`, sep=`'``,` `'`) |
Return a string representation of this MGRS grid reference. Parameters: `prec` - Optional number of digits (`int`), 4:km, 10:m. `fmt` - Optional enclosing backets format (`str`). `sep` - Optional separator between name:values (`str`). Returns: This Mgrs as "[Z:00B, G:EN, E:meter, N:meter]" (`str`). Overrides: bases.Based.toStr2

### toUtm(self, Utm=<class 'pygeodesy.utm.Utm'>) |
Convert this MGRS grid reference to a UTM coordinate. Parameters: `Utm` - Optional (sub-)class to use for the UTM coordinate (Utm) or `None`. Returns: The UTM coordinate (Utm) or 4-tuple (zone, hemisphere, easting, northing) if Utm is `None`. Example:
    >>> m = Mgrs('31U', 'DQ', 448251, 11932)
    >>> u = m.toUtm()  # 31 N 448251 5411932

Property Details

### band Get the latitudinal band (A..Z `str`). Get Method: band(self) - Get the latitudinal band (A..Z `str`). Set Method: Read_Only(self, ignored) - Throws an `AttributeError`, always.

### bandLatitude Get the band latitude (`degrees90` or `None`). Get Method: bandLatitude(self) - Get the band latitude (`degrees90` or `None`). Set Method: Read_Only(self, ignored) - Throws an `AttributeError`, always.

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

### en100k Get the 2-character grid (EN digraph `str`). Get Method: en100k(self) - Get the 2-character grid (EN digraph `str`). Set Method: Read_Only(self, ignored) - Throws an `AttributeError`, always.

### easting Gets the easting (`meter`). Get Method: easting(self) - Gets 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.

### zone Get the longitudal zone (1..60 `int`). Get Method: zone(self) - Get the longitudal zone (1..60 `int`). Set Method: Read_Only(self, ignored) - Throws an `AttributeError`, always.