Converting Eastings and Northings to Latitude and Longitude
A current project of mine involves mapping a large-ish number of coordinates from UK post codes. When geocoding a small set of addresses or postcodes, Nominatim is my go-to Python library for quick coordinates; however, the Open Street Map API is not set up for returning housands of data points. For that, I turned to the Ordnance Survey’s Code-Point Open dataset, which contains all the 1.7 million live postcodes in Great Britain.
Code-Point Open coordinates are not given in a format that can be passed directly into geopandas for GIS analysis. Ordnance Survey Eastings-Northings (OSGB36) have to be converted to latitude-longitude pairs to work with geopandas’ interactive mapping function and Folium.
The good news is that the Ordnance Survey has a beautifully simple tool that allows the batch-conversion of coordinates, Grid InQuest II. It transformed some 1.7 million coordinates in a few seconds from OSGB36 to ETRS89 geodesic.
Finally, load the resulting CSV file as a dataframe, and make a geodataframe from that in geopandas using the standard points_from_xy():
gdf = geopandas.GeoDataFrame(df, geometry=geopandas.points_from_xy(df['Longitude'], df['Latitude'], crs='ETRS89'))