Note
Go to the end to download the full example code.
MGRS grid#
Military Grid Reference System, built on UTM. Square cells whose identifier length sets precision (100 km → 1 m). Widely used for surveying and defence.
The interactive explorer below is rendered with
deck.gl and behaves like the
h3geo.org map: the MGRS precision follows the zoom and
cells are generated in the browser for whatever is in view. Two neighbouring
precisions are shown at once — the current level with a darker, heavier border
and the next finer level with a lighter, thinner one. The cell references come
from mgrs and the per-zone UTM squares from
proj4js, reproducing the exact M3S maths so the
references and edges match m3s.mgrs. MGRS only refines down to 100 km, so
it has no whole-globe level — zoom out and the explorer asks you to zoom back in.
GIS-native (lon, lat) order is used throughout.
Why MGRS?#
MGRS is for coordinates that humans read in the field: it is the NATO standard
on printed maps, GPS units and surveying gear, and because cells are true
metres in UTM, 31UDQ48 narrows down to a square you can pace out on the
ground. Use it when interoperating with defence, search-and-rescue or
surveying workflows. It is a poor analysis grid, though: cells do not tile
seamlessly across UTM zone boundaries and there is no single global
hierarchy. For coarse spoken area reference use GARS grid; for
worldwide analysis grids see EA-Quad grid or S2 grid.
Usage#
Encode a point and tile a small bounding box around Paris — same result in Python and JavaScript (both call the shared core):
import m3s
cell = m3s.MGRS.from_geometry((2.35, 48.86)) # (lon, lat)
cells = m3s.MGRS.from_geometry((2.2, 48.8, 2.4, 48.9)) # bbox
print(cell.id, len(cells))
import * as m3s from "m3s";
await m3s.ready();
const cell = m3s.MGRS.fromPoint(2.35, 48.86); // (lon, lat)
const cells = m3s.MGRS.fromBbox([2.2, 48.8, 2.4, 48.9]); // bbox
console.log(cell.id, cells.length);
from _deckmap import DeckExplorer, read_grid_js
DeckExplorer(
center=(2.35, 48.85),
zoom=7,
grid_js=read_grid_js("mgrs"),
hover="#332288",
wasm=True,
)
Total running time of the script: (0 minutes 0.011 seconds)