Registry / serialization / mgrs
library1.5.4pypypiunverified

The `mgrs` Python library (version 1.5.4) provides a simple `ctypes` wrapper around selected MGRS-related C functions from GeoTrans (version 2.4.2), an internal copy of which is included within the library. It facilitates conversions to and from Military Grid Reference System (MGRS) coordinates and decimal degrees (latitude/longitude), offering various precision levels. The library is actively maintained, with a recent release in February 2026.

pip install mgrs
INSTALL
IMPORT
SIG · MGRS
M
mgrs
serializationpythonv1.5.4
Install
1.6s avg
Import
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.5.4 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 18.1MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 1.6s · import 0.000s · 19MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

MGRS
from mgrs import MGRS
import mgrs; mgrs.MGRS()
While `import mgrs` works, it's generally cleaner to import the `MGRS` class directly for instantiation.

This quickstart demonstrates how to initialize the MGRS converter and perform common operations such as converting between latitude/longitude and MGRS, and between Degrees-Minutes-Seconds (DMS) strings and decimal degrees. Precision can also be controlled in `toMGRS()`.

from mgrs import MGRS m = MGRS() # Convert Latitude/Longitude to MGRS latitude = 42.0 longitude = -93.0 mgrs_coords = m.toMGRS(latitude, longitude) print(f"({latitude}, {longitude}) -> {mgrs_coords}") # Convert MGRS to Latitude/Longitude lat_lon_coords = m.toLatLon(mgrs_coords) print(f"{mgrs_coords} -> {lat_lon_coords}") # Convert DMS to Decimal Degrees dms_str = '321942.29N' dec_deg = m.dmstodd(dms_str) print(f"{dms_str} -> {dec_deg}") # Convert Decimal Degrees to DMS d, minute, s = m.ddtodms(dec_deg) print(f"{dec_deg} -> (D:{d}, M:{minute}, S:{s}))")
Debug
Known issues
deprecatedThe `RTreeError` exception was deprecated and aliased to `MGRSError` in version 1.4.0. Direct usage of `RTreeError` should be replaced with `MGRSError` for future compatibility.
fix
Replace `except RTreeError:` with `except MGRSError:`.
affects: >=1.4.0
breakingEarlier versions (prior to 1.3.4) were reported to incorrectly round MGRS coordinates instead of truncating them, leading to precision errors. MGRS requires truncation.
fix
Upgrade to `mgrs` version 1.3.4 or newer to ensure correct truncation behavior for MGRS coordinates.
affects: <1.3.4
gotchaFor older Python environments or manual compilation, the `mgrs` library, being a Ctypes wrapper around C code, historically had complex installation challenges on Windows without pre-built wheels. This is largely mitigated by modern `pip` and wheel distributions.
fix
Ensure you have a recent `pip` and Python (>=3.9) to leverage pre-built wheels. If issues persist, verify your C compiler setup or use a Linux/macOS environment.
affects: <1.5.0
Upgrade
Version history
1.5.4latest on PyPI · released Feb 3, 2026
Audit
Dependencies
packagingrequiredRequired for packaging metadata and wheel imports since version 1.3.9.
Agent activity
17 hits · last 30 days
node
14
Amazon
1
Resources
mgrs — pip install mgrs · libregistry