Package 'mgrsrev'

Title: What the Package Does (One Line, Title Case)
Description: What the package does (one paragraph).
Authors: Michael Sumner [aut, cre] (ORCID: <https://orcid.org/0000-0002-2471-7511>)
Maintainer: Michael Sumner <[email protected]>
License: `use_mit_license()`, `use_gpl3_license()` or friends to pick a license
Version: 0.0.0.9000
Built: 2026-06-05 07:24:08 UTC
Source: https://github.com/hypertidy/mgrsrev

Help Index


UTM CRS (EPSG code) for an MGRS zone and hemisphere

Description

UTM CRS (EPSG code) for an MGRS zone and hemisphere

Usage

mgrs_crs(zone, northp)

Arguments

zone

Integer UTM zone number (1-60).

northp

Logical or integer; TRUE/1 = northern hemisphere.

Value

Character EPSG string, e.g. "EPSG:32755".

Examples

r <- mgrs_reverse("55GEP")
mgrs_crs(r["zone"], r["northp"])
# [1] "EPSG:32755"

# Full pattern: code -> lonlat bbox
# r <- mgrs_reverse("55GEP")
# reproj::reproj_extent(r[c("xmin","xmax","ymin","ymax")],
#                       "EPSG:4326", source = mgrs_crs(r["zone"], r["northp"]))

Decode an MGRS code to a UTM bounding box

Description

Decode an MGRS code to a UTM bounding box

Usage

mgrs_reverse(code)

Arguments

code

Character MGRS code, spaces optional, e.g. "55GEP", "31UCT037872". Must be a standard UTM-zone code (GZD starts with digits 1-60). Precision 0-5 supported (4/5-char to 14/15-char codes).

Details

Returns the SW-corner bbox of the MGRS square, consistent with the NGA spec (truncation, not rounding). For precision 0, the full 100 km square; for precision N the sub-cell is 1e5 / 10^N metres on each side. Polar UPS zones (A, B, Y, Z) are not handled. No validity check is performed: any syntactically parseable code is decoded. Use mgrs_crs() to obtain the corresponding EPSG code.

Value

Named numeric vector: zone UTM zone number (1-60) northp 1 = northern hemisphere, 0 = southern xmin, xmax UTM easting of SW/NE corner (metres) ymin, ymax UTM northing of SW/NE corner (metres, false northing in S hemi)

See Also

mgrs_crs

Examples

mgrs_reverse("55GEP")
mgrs_reverse("55GEP5050")  # precision 2, 1 km cell

Vectorised wrapper around mgrs_reverse

Description

Vectorised wrapper around mgrs_reverse

Usage

mgrs_reverse_df(codes)

Arguments

codes

Character vector of MGRS codes

Value

data.frame with columns zone, northp, xmin, xmax, ymin, ymax