Package 'mgrs'

Title: Convert 'MGRS' ('Military Grid Reference System') Coordinates From/To Other Coordinate Systems
Description: The 'Military Grid Reference System' ('MGRS') is the geocoordinate standard used by 'NATO' militaries for locating points on the earth. The 'MGRS' is derived from the 'Universal Transverse Mercator' ('UTM') grid system and the universal polar stereographic ('UPS') grid system, but uses a different labeling convention. The 'MGRS' is used for the entire earth. Methods are provided to convert 'MGRS' coordinates to and from other coordinate systems.
Authors: Bob Rudis [aut, cre] , Gregory Smith [ctb]
Maintainer: Bob Rudis <[email protected]>
License: MIT + file LICENSE
Version: 0.2.4
Built: 2025-02-13 11:42:42 UTC
Source: https://github.com/hrbrmstr/mgrs

Help Index


Convert latitude/longitude to MGRS string

Description

Convert latitude/longitude to MGRS string

Usage

latlng_to_mgrs(latitude, longitude, degrees = TRUE, precision = 5L)

Arguments

latitude, longitude

coordinates

degrees

are latitude/longitude in degrees? Default: TRUE

precision

0:5; level of precision for the conversion. Default 5

Examples

latlng_to_mgrs(42, -93)

Convert 'MGRS' ('Military Grid Reference System') Coordinates From/To Other Coordinate Systems

Description

The 'Military Grid Reference System' ('MGRS') is the geocoordinate standard used by 'NATO' militaries for locating points on the earth. The 'MGRS' is derived from the 'Universal Transverse Mercator' ('UTM') grid system and the universal polar stereographic ('UPS') grid system, but uses a different labeling convention. The 'MGRS' is used for the entire earth. Methods are provided to convert 'MGRS' coordinates to and from other coordinate systems.

Details

The origin of the MGRS grid, in the Pacific. Honolulu is in 4QFJ.

Figure: The origin of the MGRS grid, in the Pacific. Honolulu is in 4QFJ

CC-BY-SA 3.0

Author(s)

boB Rudis ([email protected])

See Also

Useful links:


Return MGRS grid reference precision (in meters)

Description

MGRS coordinates represent a "square" with a certain level of precision. See Details for more info.

Usage

mgrs_precision(x)

Arguments

x

character vector of MGRS grid references

Details

An MGRS grid reference is a point reference system. When the term 'grid square' is used, it can refer to a square with a side length of 10 km (6 mi), 1 km, 100 m (328 ft), 10 m or 1 m, depending on the precision of the coordinates provided. (In some cases, squares adjacent to a Grid Zone Junction (GZJ) are clipped, so polygon is a better descriptor of these areas.) The number of digits in the numerical location must be even: 0, 2, 4, 6, 8 or 10, depending on the desired precision. When changing precision levels, it is important to truncate rather than round the easting and northing values to ensure the more precise polygon will remain within the boundaries of the less precise polygon. Related to this is the primacy of the southwest corner of the polygon being the labeling point for an entire polygon. In instances where the polygon is not a square and has been clipped by a grid zone junction, the polygon keeps the label of the southwest corner as if it had not been clipped.

For example (spaces used for clarity):

4Q

precision level 6x8 degrees (in most cases) - function returns NA for this

4QFJ

precision level 100 km

4QFJ 1 6

precision level 10 km

4QFJ 12 67

precision level 1 km

4QFJ 123 678

precision level 100 m

4QFJ 1234 6789

precision level 10 m

4QFJ 12345 67890

precision level 1 m

Value

data frame with grid_ref and precision columns. precision is in meters.

References

https://en.wikipedia.org/wiki/Military_Grid_Reference_System#Grid_zone_designation

Examples

grefs <- c("4Q", "4QFJ", "4QFJ16", "4QFJ1267", "4QFJ123678",
           "4QFJ12346789", "4QFJ1234567890")
mgrs_precision(grefs)

Convert an MGRS string to latitude/longitude

Description

Convert an MGRS string to latitude/longitude

Usage

mgrs_to_latlng(MGRS, degrees = TRUE, include_mgrs_ref = TRUE)

Arguments

MGRS

an MGRS string

degrees

convert to degrees? Default: TRUE

include_mgrs_ref

if TRUE the data frame returned fill include the MGRS reference in a column named mgrs. Default: TRUE.

Value

data.frame

Note

vectorized

Examples

mgrs_to_latlng("15TWG0000049776")

Convert MGRS to UPS

Description

Convert MGRS to UPS

Usage

mgrs_to_ups(mgrs_string, include_mgrs_ref = TRUE)

Arguments

mgrs_string

a character vector of MGRS strings

include_mgrs_ref

if TRUE the data frame returned fill include the MGRS reference in a column named mgrs. Default: TRUE.

Value

data.frame

Note

vectorized

Examples

mgrs_to_ups("ZGC2677330125")

Convert MGRS to UTM

Description

Convert MGRS to UTM

Usage

mgrs_to_utm(mgrs_string, include_mgrs_ref = TRUE)

Arguments

mgrs_string

acharacter vector of MGRS strings

include_mgrs_ref

if TRUE the data frame returned fill include the MGRS reference in a column named mgrs. Default: TRUE.

Value

data.frame

Note

vectorized

Examples

mgrs_to_utm("48PUV7729883034")

Convert UPS to Latitude/Longitude

Description

Convert UPS to Latitude/Longitude

Usage

ups_to_latlng(hemisphere, easting, northing, degrees = TRUE)

Arguments

hemisphere

South (S) or North (N)

easting, northing

easting (X) / northing (Y) (meters)

degrees

convert to degrees? Default: TRUE

Examples

ups_to_latlng("N", 2426773, 1530125)

Convert UPS to MGRS

Description

Convert UPS to MGRS

Usage

ups_to_mgrs(hemisphere, easting, northing, precision = 5L)

Arguments

hemisphere

South (S) or North (N)

easting, northing

easting (X) / northing (Y) (meters)

precision

0:5; level of precision for the conversion. Default 5

Examples

ups_to_mgrs("N", 2426773, 1530125)

Convert UTM to Latitude/Longitude

Description

Convert UTM to Latitude/Longitude

Usage

utm_to_latlng(zone, hemisphere, easting, northing, degrees = TRUE)

Arguments

zone

1:60

hemisphere

South (S) or North (N)

easting, northing

easting (X) / northing (Y) (meters)

degrees

convert to degrees? Default: TRUE

Examples

utm_to_latlng(48, "N", 377299, 1483035)

Convert UTM to MGRS

Description

Convert UTM to MGRS

Usage

utm_to_mgrs(zone, hemisphere, easting, northing, precision = 5L)

Arguments

zone

1:60

hemisphere

South (S) or North (N)

easting, northing

easting (X) / northing (Y) (meters)

precision

0:5; level of precision for the conversion. Default 5

Examples

utm_to_mgrs(48, "N", 377299, 1483035)