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.

travisstatus

ChangeLog

1.4.0

  • Alias and deprecate RTreeError #33

1.3.9

  • MGRS now requires packaging library #31

  • Fix wheel imports of shared libs

1.3.8

  • UTF-8 encoding for all strings.

  • Fix #29 implicit tuple on return of UTMToMGRS

1.3.7

  • automated building of osx, linux and win64 wheels

  • Migrate from TravisCI => GitHub Actions

  • Warnings cleanup

  • flake8 validation

1.3.6

1.3.4

1.3.3

1.3.2

  • Better Windows support

  • Bug fix for 3 digit longitudes

1.3.1

  • Python 3.x support

  • Allow user to override precision in UTMToMGRS

Usage

In a nutshell:

>>> import mgrs

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

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

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

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

>>> 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.0.tar.gz (31.8 kB view hashes)

Uploaded Source

Built Distributions

mgrs-1.4.0-cp38-cp38-win_amd64.whl (23.2 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

mgrs-1.4.0-cp38-cp38-manylinux1_x86_64.whl (47.6 kB view hashes)

Uploaded CPython 3.8

mgrs-1.4.0-cp38-cp38-macosx_10_14_x86_64.whl (21.9 kB view hashes)

Uploaded CPython 3.8 macOS 10.14+ x86-64

mgrs-1.4.0-cp37-cp37m-win_amd64.whl (23.2 kB view hashes)

Uploaded CPython 3.7m Windows x86-64

mgrs-1.4.0-cp37-cp37m-manylinux1_x86_64.whl (47.6 kB view hashes)

Uploaded CPython 3.7m

mgrs-1.4.0-cp37-cp37m-macosx_10_14_x86_64.whl (21.9 kB view hashes)

Uploaded CPython 3.7m macOS 10.14+ x86-64

mgrs-1.4.0-cp36-cp36m-win_amd64.whl (23.2 kB view hashes)

Uploaded CPython 3.6m Windows x86-64

mgrs-1.4.0-cp36-cp36m-manylinux1_x86_64.whl (47.6 kB view hashes)

Uploaded CPython 3.6m

mgrs-1.4.0-cp36-cp36m-macosx_10_14_x86_64.whl (21.9 kB view hashes)

Uploaded CPython 3.6m macOS 10.14+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page