osgb_fwd: Ordnance Survey National Grid (Great Britain)

View source: R/osgb.R

osgb_fwdR Documentation

Ordnance Survey National Grid (Great Britain)

Description

Convert between geographic coordinates and the Ordnance Survey National Grid used in Great Britain.

Important: These functions expect coordinates on the OSGB36 datum, not WGS84. For WGS84 coordinates (e.g., from GPS), you need to perform a datum transformation first using another package such as sf.

Usage

osgb_fwd(x)

osgb_rev(easting, northing)

osgb_gridref(x, precision = 2L)

osgb_gridref_rev(gridref)

Arguments

x

For osgb_fwd() and osgb_gridref(): a two-column matrix or data frame of OSGB36 coordinates (longitude, latitude) in decimal degrees.

easting

Numeric vector of OSGB eastings in meters.

northing

Numeric vector of OSGB northings in meters.

precision

Integer specifying the precision of grid references:

  • -1: 500 km squares (first letter only)

  • 0: 100 km squares (two letters)

  • 1: 10 km (2 digits)

  • 2: 1 km (4 digits)

  • 3: 100 m (6 digits)

  • 4: 10 m (8 digits)

  • 5: 1 m (10 digits)

gridref

Character vector of OSGB grid reference strings.

Details

The Ordnance Survey National Grid is a geographic grid reference system used in Great Britain. It uses the OSGB36 datum and a Transverse Mercator projection.

Grid references are alphanumeric codes like "TQ3080" for central London. The format is two letters (100 km square) followed by an even number of digits.

Datum note: The difference between WGS84 and OSGB36 can be up to ~100m. For precise work, transform WGS84 coordinates to OSGB36 first.

Value

  • osgb_fwd(): Data frame with columns:

    • easting: OSGB easting in meters

    • northing: OSGB northing in meters

    • convergence: Grid convergence in degrees

    • scale: Scale factor

    • lon, lat: Input OSGB36 coordinates (echoed)

  • osgb_rev(): Data frame with columns:

    • lon: OSGB36 longitude in decimal degrees

    • lat: OSGB36 latitude in decimal degrees

    • convergence: Grid convergence in degrees

    • scale: Scale factor

    • easting, northing: Input coordinates (echoed)

  • osgb_gridref(): Character vector of grid reference strings.

  • osgb_gridref_rev(): Data frame with columns:

    • lon: OSGB36 longitude in decimal degrees

    • lat: OSGB36 latitude in decimal degrees

    • easting: OSGB easting in meters

    • northing: OSGB northing in meters

    • precision: Precision level of the grid reference

Examples

# OSGB36 coordinates for central London (not WGS84!)
# In practice, you would transform from WGS84 first
london_osgb36 <- c(-0.1270, 51.5072)

# Convert to OSGB grid
osgb_fwd(london_osgb36)

# Get grid reference at various precisions
osgb_gridref(london_osgb36, precision = 2)  # 1 km
osgb_gridref(london_osgb36, precision = 3)  # 100 m
osgb_gridref(london_osgb36, precision = 4)  # 10 m

# Parse a grid reference
osgb_gridref_rev("TQ3080")

# Round-trip conversion
fwd <- osgb_fwd(london_osgb36)
osgb_rev(fwd$easting, fwd$northing)

geographiclib documentation built on March 4, 2026, 9:07 a.m.