Skip to contents

This function takes a vector of MGRS (Military Grid Reference System) cell codes and determines the most likely UTM (Universal Transverse Mercator) coordinate reference system (CRS) in EPSG format. It extracts the UTM zone and determines the hemisphere (North or South) based on the letter codes.

Usage

get_crs_for_mgrs(cellcodes)

Arguments

cellcodes

A character vector of MGRS grid cell codes (e.g., "32UMA", "33TWE").

Value

A character string representing the most probable EPSG code for the given cell codes, for example, "EPSG:32632".

Examples

# Example with MGRS codes from a Northern Hemisphere zone (Zone 32)
mgrs_codes_north <- c("32TMT", "32TMR", "32TML")
get_crs_for_mgrs(mgrs_codes_north)
#> [1] "EPSG: 32632"

# Example with MGRS codes from a Southern Hemisphere zone (Zone 14)
mgrs_codes_south <- c("14KMF", "14KMJ", "14KMG")
get_crs_for_mgrs(mgrs_codes_south)
#> [1] "EPSG: 32714"

# The function can handle a mix of zones, choosing the median
mgrs_mixed_zones <- c("27TMT", "28TMR", "29TWE")
get_crs_for_mgrs(mgrs_mixed_zones)
#> [1] "EPSG: 32628"