OSGB is the Ordnance Survey National Grid and is used for many grid references in the United Kingdom. This grid system works well for locations within the United Kingdom, but needs work if you need to combine coordinates from another system, or perhaps plot locations on open streetmap. In this post I look at python OSGB to WGS84 conversion.
Converting between OSGB and WGS84 is possible, but it is rather involved. Thankfully there are already some Python OSGB to WGR84 conversion modules that we can use.
Use the bng-latlon module
You can install the bng-latlon module with
pip install bng_latlon
and use it with:
from bng_to_latlon import OSGB36toWGS84 OSGB36toWGS84(538890, 177320)
which gives the output
It is also possible to convert from WGS84 back to OSGB with:
from latlon_to_bng import WGS84toOSGB36 WGS84toOSGB36(51.4778, -0.0014)
which gives the output as OSGB coordinates:
Dealing With OSGB Letter Codes
One of the features (peculiarities?) of the OBGR system is that it can be represented by both letter or numbers. The bng-latlon package doesn’t account for these letter codes, so you may need to use a different module for Python OSGB to WGR84 conversion such as pyproj, or osgb.