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

Module mgrs

Military Grid Reference System (MGRS/NATO) class Mgrs and functions parseMGRS and toMgrs.

Pure Python implementation of MGRS / UTM conversion functions using an ellipsoidal earth model, transcribed from JavaScript originals by (C) Chris Veness 2014-2016 published under the same MIT Licence**, see http://www.movable-type.co.uk/scripts/latlong-utm-mgrs.html and http://www.movable-type.co.uk/scripts/geodesy/docs/module-mgrs.html.

The MGRS/NATO grid references provides geocoordinate references covering the entire globe, based on UTM projections.

MGRS references comprise a grid zone designation, a 100 km square identification, and an easting and northing (in metres).

Depending on requirements, some parts of the reference may be omitted (implied), and easting/northing may be given to varying resolution.

Qv http://www.fgdc.gov/standards/projects/FGDC-standards-projects/usng/fgdc_std_011_2001_usng.pdf and http://wikipedia.org/wiki/Military_grid_reference_system.


Version: 17.06.04

Classes
  Mgrs
Military Grid Reference System (MGRS/NATO) references, with method to convert to UTM coordinates.
Functions
 
parseMGRS(strMGRS, datum=Datum(name='WGS84', ellipsoid=Ellipsoids.WGS84, transform=Tran...)
Parse a string representing a MGRS grid reference, consisting of zoneBand, grid, easting and northing.
 
toMgrs(utm, Mgrs=<class 'pygeodesy.mgrs.Mgrs'>)
Convert a UTM coordinate to an MGRS grid reference.
Function Details

parseMGRS(strMGRS, datum=Datum(name='WGS84', ellipsoid=Ellipsoids.WGS84, transform=Tran...)

 

Parse a string representing a MGRS grid reference, consisting of zoneBand, grid, easting and northing.

Parameters:
  • strMGRS - MGRS grid reference (string).
  • datum - The datum to use (Datum).
Returns:
The MGRS grid reference (Mgrs).
Raises:
  • ValueError - Invalid strMGRS.

Example:

>>> m = parseMGRS('31U DQ 48251 11932')
>>> str(m)  # 31U DQ 48251 11932
>>> m = parseMGRS('31UDQ4825111932')
>>> repr(m)  # [Z:31U, G:DQ, E:48251, N:11932]

toMgrs(utm, Mgrs=<class 'pygeodesy.mgrs.Mgrs'>)

 

Convert a UTM coordinate to an MGRS grid reference.

Parameters:
  • utm - A UTM coordinate (Utm).
  • Mgrs - Mgrs class for the MGRS grid reference (Mgrs).
Returns:
The MGRS grid reference (Mgrs).
Raises:
  • TypeError - If utm is not Utm.
  • ValueError - Invalid utm.

Example:

>>> u = Utm(31, 'N', 448251, 5411932)
>>> m = u.toMgrs()  # 31U DQ 48251 11932