Skip to content
Convert between British National Grid coordinates and WGS84 longitude and latitude, in Julia
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


Build Status Build status Coverage Status

Convert between WGS84 coordinates and British National Grid references

BritishNationalGrid provides the type BNGPoint to convert between longitude-latitude and grid references in the British National Grid system. It assumes your points are geodetic longitude and latitude in decimal degrees using the WGS84 ellipsoid.

This package is reliable to within a metre or so. Advanced users needing greater accuracy will probably already know how to convert between different systems, but any additions to the package that remain easy to use will be welcome.


julia> import Pkg

julia> Pkg.add("BritishNationalGrid")


Construct points in the grid using BNGPoint.

julia> using BritishNationalGrid

julia> p1 = BNGPoint(42513, 100231) # Full grid reference
BNGPoint{Int64}(42513, 100231)

julia> lonlat(p1) # Convert to longitude-latitude (°)
(-7.063648859478239, 50.69155306935914)

julia> p2 = BNGPoint(lon=0.32, lat=51.0) # Construct point from lon-lat
BNGPoint{Float64}(562885.4557430055, 124851.2191743746)

julia> p3 = BNGPoint(00123, 51422, "TA") # Construct from 100 km square name
BNGPoint{Int64}(500123, 451422)

Get a formatted grid reference:

julia> gridref(p1, 10) # 10-figure grid reference
"04251 10023"

julia> gridref(p2, 6, true) # 6-figure reference within the 100 km square TQ
"TQ 628 248"

Find the 100 km square in which a point lies:

julia> square(p3)


Other ways to convert to the British National Grid

  • Use the Ordnance Survey's online converter. This also includes links to the OS's Pascal programs to do coordinate transforms.
  • Use the British Geological Survey's online converter, which also assumes WGS84 longitude and latitude.
You can’t perform that action at this time.