| gars_fwd | R Documentation |
Convert geographic coordinates (longitude/latitude) to GARS codes, or convert GARS codes back to coordinates.
gars_fwd(x, precision = 2L)
gars_rev(gars)
x |
A two-column matrix or data frame of coordinates (longitude, latitude) in decimal degrees, or a list with longitude and latitude components. Can also be a length-2 numeric vector for a single point. |
precision |
Integer specifying the precision level (0, 1, or 2):
|
gars |
Character vector of GARS codes to convert back to coordinates. |
GARS (Global Area Reference System) is a standardized geospatial reference system used by the US military. It divides the Earth into cells using a hierarchical grid:
30-minute cells: The base grid (720 × 360 cells globally)
15-minute quadrants: Each 30-minute cell divided into 4 quadrants (1-4)
5-minute keypads: Each quadrant divided into 9 keypads (1-9, like a phone keypad)
A GARS code consists of:
3-digit longitude band (001-720)
2-letter latitude band (AA-QZ)
Optional 1-digit quadrant (1-4)
Optional 1-digit keypad (1-9)
Example: "006AG39" = 5-minute cell at approximately (-177°, -89.5°)
gars_fwd(): Character vector of GARS codes.
gars_rev(): Data frame with columns:
lon: Longitude of cell center in decimal degrees
lat: Latitude of cell center in decimal degrees
precision: Precision level (0, 1, or 2)
lat_resolution: Cell half-height in degrees
lon_resolution: Cell half-width in degrees
mgrs_fwd() for Military Grid Reference System, another military
grid system.
# Basic conversion
gars_fwd(c(-74, 40.7))
# Different precision levels
gars_fwd(c(-74, 40.7), precision = 0) # 30-minute
gars_fwd(c(-74, 40.7), precision = 1) # 15-minute
gars_fwd(c(-74, 40.7), precision = 2) # 5-minute
# Multiple points
pts <- cbind(lon = c(-74, 139.7, 0), lat = c(40.7, 35.7, 51.5))
gars_fwd(pts, precision = 2)
# Reverse conversion
gars_rev(c("213LR29", "498MH18", "361NS47"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.