Search code examples
pythonpandaslatitude-longitudegeopandas

Convert Irish Grid (Northings & Eastings) to Correct Northings & Eastings


I have a CSV file that has columns for Latitude and Longitude. The data for each is in the Irish Grid Coordinate System (Northings & Eastings). How do I convert to correct latitude and longitude?

Example of what I have Latitude 372000 Longitude 332000.

Code

from shapely.geometry import Point
import geopandas as gpd
from geopandas import GeoDataFrame
import pandas as pd

df = pd.read_csv("File.csv", skiprows=0, low_memory=False, encoding='ANSI')

geometry = [Point(xy) for xy in zip(df['longitude'], df['latitude'])]
gdf = GeoDataFrame(df, geometry=geometry)   

#this is a simple map that goes with geopandas
world = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))

gdf.plot(ax=world.plot(figsize=(10, 6)), color='red', markersize=1.5)

Solution

  • I believe the Irish Grid uses CRS 29903 (as per https://georepository.com/crs_29903/TM75-Irish-Grid.html), while the world file that comes with GeoPandas uses CRS 4326. So you either have to reproject the first to the second, or vice versa.

    Something like:

    gdf = gdf.to_crs(4326)
    

    or

    world = world.to_crs(29903)
    

    you can then check this with (using Jupyter here):

    In: world.crs
    
    Out:
    

    Name: TM75 / Irish Grid Axis Info [cartesian]:

    • E[east]: Easting (metre)
    • N[north]: Northing (metre) Area of Use:
    • name: Europe - Ireland (Republic and Ulster) - onshore
    • bounds: (-10.56, 51.39, -5.34, 55.43) Coordinate Operation:
    • name: Irish Grid
    • method: Transverse Mercator Datum: Geodetic Datum of 1965
    • Ellipsoid: Airy Modified 1849
    • Prime Meridian: Greenwich

    So putting this all together (assuming that the implicit CRS of your .csv is really 29903, it would look like this:

    df = pd.read_csv("File.csv", skiprows=0, low_memory=False, encoding='ANSI')
    geometry = [Point(xy) for xy in zip(df['longitude'], df['latitude'])]
    gdf = GeoDataFrame(df, geometry=geometry, crs= 29903) 
    gdf = gdf.to_crs(4326)
    world = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))
    gdf.plot(ax=world.plot(figsize=(10, 6)), color='red', markersize=1.5)
    

    And you get geometry values that look like this:

    0       POINT (-6.45067 53.35318)
    1       POINT (-6.44943 53.35470)
    2       POINT (-6.44432 53.35355)
    3       POINT (-6.43974 53.34900)
    4       POINT (-6.44179 53.34956)
    

    enter image description here