I have a file in British National Grid coordinates (EPSG 27700) which I'm trying to convert to WGS84 (EPSG 4326)
My first attempt was to transform in the usual way
import geopandas as gpd
file = '27700.gpkg'
sh = gpd.read_file(file)
sh = sh.to_crs(epsg = 4326)
sh.to_file('out')
Now this runs just fine, but when I open the resulting file in QGIS I see that the files in fact do not overlap!
The only reason I can think of is that the re projection used by QGIS is different than the one used by pyproj.
I then tried all reprojections available for pyproj as follows
from pyproj.transformer import TransformerGroup
import geopandas as gpd
import numpy as np
from functools import partial
from shapely.geometry import Point
from shapely.ops import transform
trans_group = TransformerGroup("epsg:27700","epsg:4326")
#you can see there are multiple trasnsformers possible
print(trans_group)
file = '27700'
sh = gpd.read_file(file)
i=0
for i in np.arange(len(trans_group.transformers)):
transformer = partial(transform, trans_group.transformers[i].transform)
sh_new = sh.copy()
sh_new.set_geometry(sh.geometry.apply(transformer), inplace=True, crs = 4326)
sh_new['geometry'] = sh_new.geometry.apply(swap_xy)
sh_new.to_file('out' + str(i))
But when opening these output files in QGIS non of them matched!
I also tried ogr2ogr
ogr2ogr out.gpkg -t_srs "EPSG:4326" in.gpkg
Again the output file does not match the input file.
Can there be some reason why my pyproj uses a wrong formula? Is there anyway to update the projection formulas that my pyproj is using?
In this image you can see that the original and new file indeed do not fully overlap (one is in red the other in gray)