| osgb_fwd | R Documentation |
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.
osgb_fwd(x)
osgb_rev(easting, northing)
osgb_gridref(x, precision = 2L)
osgb_gridref_rev(gridref)
x |
For |
easting |
Numeric vector of OSGB eastings in meters. |
northing |
Numeric vector of OSGB northings in meters. |
precision |
Integer specifying the precision of grid references:
|
gridref |
Character vector of OSGB grid reference strings. |
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.
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
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.