Skip to main content

MGRS coordinate conversion for Python

Project description

mgrs: Converting to and from MGRS and Decimal Degrees

GeoTrans provides C code for converting to and from MGRS, but well, it’s C code :). This is a simple ctypes wrapper around two of the MGRS-related functions in GeoTrans.

This library has an internal copy of some of the files from GeoTrans 2.4.2.



  • Wheels
  • black, flake8, and isort linters


  • GitHub Action builders needed to be changed to push release


  • Fix install requirements #34


  • Alias and deprecate RTreeError #33


  • MGRS now requires packaging library #31
  • Fix wheel imports of shared libs


  • UTF-8 encoding for all strings.
  • Fix #29 implicit tuple on return of UTMToMGRS


  • automated building of osx, linux and win64 wheels
  • Migrate from TravisCI => GitHub Actions
  • Warnings cleanup
  • flake8 validation





  • Better Windows support
  • Bug fix for 3 digit longitudes


  • Python 3.x support
  • Allow user to override precision in UTMToMGRS


In a nutshell:

>>> import mgrs

>>> latitude = 42.0
>>> longitude = -93.0

>>> m = mgrs.MGRS()
>>> c = m.toMGRS(latitude, longitude)
>>> c

>>> d = m.toLatLon(c)
>>> d
(41.999997975127997, -93.000000000000014)

>>> y = '321942.29N'
>>> yd = m.dmstodd(y)

>>> d, m, s = m.ddtodms(32.328414)
>>> d, m, s
(32.0, 19.0, 42.290400)

You can also control the precision of the MGRS grid with the MGRSPrecision arguments in .toMGRS(). Other than that, there isn’t too much to it.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mgrs-1.4.5.tar.gz (31.3 kB view hashes)

Uploaded source

Built Distributions

mgrs-1.4.5-cp310-cp310-win_amd64.whl (24.1 kB view hashes)

Uploaded cp310

mgrs-1.4.5-cp310-cp310-macosx_11_0_arm64.whl (21.4 kB view hashes)

Uploaded cp310

mgrs-1.4.5-cp39-cp39-win_amd64.whl (24.1 kB view hashes)

Uploaded cp39

mgrs-1.4.5-cp39-cp39-macosx_11_0_arm64.whl (21.4 kB view hashes)

Uploaded cp39

mgrs-1.4.5-cp38-cp38-win_amd64.whl (24.1 kB view hashes)

Uploaded cp38

mgrs-1.4.5-cp38-cp38-macosx_11_0_arm64.whl (21.4 kB view hashes)

Uploaded cp38

mgrs-1.4.5-cp37-cp37m-win_amd64.whl (24.1 kB view hashes)

Uploaded cp37

mgrs-1.4.5-cp36-cp36m-win_amd64.whl (24.8 kB view hashes)

Uploaded cp36

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page