Converting Northing and Easting to Latitude and Longitude

I am in the epic task of resurrecting very old posts and this is one I wrote probably 8 years ago and I think it is worth having at hand for future generations ;-)

At the time of the original post I was analysing demand based on location and weather data. I was using the Ordnance Survey Code-Point® Open to pinpoint weather stations, customers, boundaries, etc. Code-Point® comes with Northing and Easting which is how the British National Grid is defined instead of Latitude and Longitude and for my final solution I needed all my analysis and data in Lat & Lng.

Here is the updated solution as pyproj has moved on and some of the syntax has been (or will be) deprecated.

from pyproj import CRS, Transformer

# Lat & lng EPSG:4326 projection (Google maps, etc)
crs_4326 = CRS("WGS84") 

# British National Grid
crs_northing_easting = CRS("EPSG:27700") 

## Create our coversion from -> to
transformer = Transformer.from_crs(crs_northing_easting,crs_4326)

print(transformer.transform(394251, 806376))
## (57.14823165785533, -2.0966478399737762)

Hope this help others as it did help me back in 2012.


comments powered by Disqus