Unfortunately my projection from Irish Transverse Mercator (ITM) to WGS84 latitude-longitude seems to have gone wrong as the plotted coordinates don't line up with a map of Dublin sourced from the CSO (see below).
My transformed coordinates plotted on a map of Dublin
The transformed data was sourced from the Irish Valuation Office and the ITM X & Y coordinates were fed into a function adapted from a previous stackoverflow discussion which uses geopandas' built-in points_from_xy method to transform coordinates between Coordinate Reference Systems:
def create_geodf_from_GPS (df, latitude, longitude, crs):
locations = gpd.points_from_xy(longitude, latitude)
geo_df = gpd.GeoDataFrame(df, geometry=locations)
geo_df.crs = crs
return geo_df
VO_geo = create_geodf_from_GPS(VO, VO[" X ITM"], VO[" Y ITM"], crs = 'epsg:2157')
VO_geo = VO_geo.to_crs('epsg:4326')
Does anyone have any idea what may have gone wrong here?
Very simple fix thanks to @joris
Altered function using x & y as arguments for gpd.points_from_xy instead of the previously mixed up longitude & latitude:
def create_geodf_from_GPS (df, x, y, crs):
locations = gpd.points_from_xy(x, y)
geo_df = gpd.GeoDataFrame(df, geometry=locations)
geo_df.crs = crs
return geo_df
Now plotting the data in WGS84 latitude-longitude works as expected:
VO_geo = create_geodf_from_GPS(VO, x=VO[" X ITM"], y=VO[" Y ITM"], crs = 'epsg:2157')
VO_geo.to_crs('epsg:4326').plot()
Note: the data had to be cleaned to remove obvious outliers by filtering out non-Dublin data using geopandas' (gpd) spatial join function
VO_geo_clean = gpd.sjoin(VO_geo.to_crs('epsg:4326'), map_of_Dublin)