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

Class Mgrs

object --+    
         |    
bases.Base --+
             |
            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...)
New Mgrs grid reference.
 
parse(self, strMGRS)
Parses a string to a MGRS grid reference.
 
toStr(self, prec=10, sep=' ')
Returns a string representation of this MGRS grid reference.
 
toStr2(self, prec=10, fmt='[%s]', sep=', ')
Returns a string representation of this MGRS grid reference.
 
toUtm(self)
Converts this MGRS grid reference to a UTM coordinate.

Inherited from bases.Base: __repr__, __str__, classname, others, topsub

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __subclasshook__

Properties
  band
Gets the latitudinal band A..Z (string).
  bandLatitude
Gets the band latitude (degrees90 or None).
  datum
Gets the datum (Datum).
  en100k
Gets the 2-character grid EN digraph (string).
  easting
Gets the easting (meter).
  northing
Gets the northing (meter).
  zone
Gets the longitudal zone 1..60 (int).

Inherited from object: __class__

Method Details

__init__(self, zone, en100k, easting, northing, band='', datum=Datum(name='WGS84', ellipsoid=Ellipsoids.WGS84, transform=Tran...)
(Constructor)

 

New Mgrs grid reference.

Parameters:
  • zone - 6° longitudinal zone, 1..60 covering 180°W..180°E (int).
  • en100k - Two-letter EN digraph, 100 km grid square (string).
  • easting - Easting in meter within 100 km grid square (scalar).
  • northing - Northing in meter within 100 km grid square (scalar).
  • band - 8° latitudinal band, C..X covering 80°S..84°N (string).
  • datum - This reference's datum (Datum).
Raises:
  • ValueError - Invalid MGRS grid reference.
Overrides: object.__init__

Example:

>>> from mgrs import Mgrs
>>> m = Mgrs('31U', 'DQ', 48251, 11932)  # 31U DQ 48251 11932

parse(self, strMGRS)

 

Parses a string to a MGRS grid reference.

For details, see function parseMGRS in this module mgrs.

Parameters:
  • strMGRS - MGRS grid reference (string).
Returns:
MGRS reference (Mgrs).

toStr(self, prec=10, sep=' ')

 

Returns a string representation of this MGRS grid reference.

Note that MGRS grid references are truncated, not rounded (unlike UTM coordinates).

Parameters:
  • prec - Number of digits, 4:km, 10:m (int).
  • sep - Separator to join (string).
Returns:
This Mgrs as "00B EN easting northing" (string).
Overrides: bases.Base.toStr

Example:

>>> m = Mgrs(31, 'DQ', 48251, 11932, band='U')
>>> m.toStr()  # '31U DQ 48251 11932'

toStr2(self, prec=10, fmt='[%s]', sep=', ')

 

Returns a string representation of this MGRS grid reference.

Parameters:
  • prec - Number of digits, 4:km, 10:m (int).
  • fmt - Enclosing backets format (string).
  • sep - Separator between name:values (string).
Returns:
This Mgrs as "[Z:00B, G:EN, E:meter, N:meter]" (string).
Overrides: bases.Base.toStr2

toUtm(self)

 

Converts this MGRS grid reference to a UTM coordinate.

Returns:
The UTM coordinate (Utm).

Example:

>>> m = Mgrs('31U', 'DQ', 448251, 11932)
>>> u = m.toUtm()  # 31 N 448251 5411932


Property Details

band

Gets the latitudinal band A..Z (string).

Get Method:
band(self) - Gets the latitudinal band A..Z (string).

bandLatitude

Gets the band latitude (degrees90 or None).

Get Method:
bandLatitude(self) - Gets the band latitude (degrees90 or None).

datum

Gets the datum (Datum).

Get Method:
datum(self) - Gets the datum (Datum).

en100k

Gets the 2-character grid EN digraph (string).

Get Method:
en100k(self) - Gets the 2-character grid EN digraph (string).

easting

Gets the easting (meter).

Get Method:
easting(self) - Gets the easting (meter).

northing

Gets the northing (meter).

Get Method:
northing(self) - Gets the northing (meter).

zone

Gets the longitudal zone 1..60 (int).

Get Method:
zone(self) - Gets the longitudal zone 1..60 (int).