Coordinate System – Comparative Analysis Between Pyproj and GeoPandas for Coordinate Transformations

coordinate systemcoordinatesgeopandaspyprojtransformer

When using the Pyproj function "TransformerGroup", I detected that for the CRS: "Camacupa 1948 / TM 12 SE – EPSG:22092" there is the possibility of executing the coordinate transformation from 6 different geodetic models.

When analyzing my results performing the operation by GeoPandas, I found that for the situation mentioned above, the coordinate transformation model used by GeoPandas is the one considered less relevant by Pyproj.

Considering the situation presented and the need to convert data according to specific geodetic models, does GeoPandas allow the user to choose the desired conversion model?

########################################################################################

#Camacupa 1948 / TM 12 SE - EPSG:22092 
coord = (-11.5,12.5) # lat e long 
from pyproj.transformer import TransformerGroup
tg = TransformerGroup(4326, 22092)
print(tg.best_available)
print()
print(tg.transformers[i].description)
print(tg.transformers[i].transform(coord[0], coord[1]))
for i in range(len(tg.transformers)):
     transformer = Transformer.from_crs(4326, 22092)
     print()
     print(transformer.transform(coord[0], coord[1]))

True

Inverse of Camacupa 1948 to WGS 84 (10) + TM 12 SE
(554857.9414755455, 8728916.009087056) # more relevant
Inverse of Camacupa 1948 to WGS 84 (9) + TM 12 SE
(554869.5938452879, 8728910.618398817)
Inverse of Camacupa 1948 to WGS 84 (2) + TM 12 SE
(554866.5311228175, 8728907.292482024)
Inverse of Camacupa 1948 to WGS 84 (1) + TM 12 SE
(554844.8394307916, 8728912.414008332)
Inverse of Camacupa 1948 to WGS 84 (6) + TM 12 SE
(554849.3061784751, 8728915.989082552)
Ballpark geographic offset from WGS 84 to Camacupa 1948 + TM 12 SE
(554529.5161391391, 8728801.523080738) # less relevant

(554529.5161391391, 8728801.523080738) # less relevant

from shapely.geometry import Point
d = {'col1': ['name1'], 'geometry': [Point(12.5, -11.5)]}
gdf = gpd.GeoDataFrame(d, crs=4326)
gdf = gdf.to_crs(22092)
gdf['Norte'] = gdf.geometry.y
gdf['Este'] = gdf.geometry.x
print(gdf)

col1 geometry Norte Este
0 name1 POINT (554529.516 8728801.523) 8.728802e+06 554529.516139

Best Answer

Not directly with to_crs e.g. Issue 1175, but you can do the transform yourself:

from functools import partial
from pyproj.transformer import TransformerGroup
from shapely.geometry import Point
from shapely.ops import transform
import geopandas as gpd


transformer = TransformerGroup(4326, 22092).transformers[0]
transformer = partial(transform, transformer.transform)

d = {'col1': ['name1'], 'geometry': [Point(-11.5, 12.5)]}
gdf = gpd.GeoDataFrame(d, crs=4326)
gdf.set_geometry(gdf.geometry.apply(transformer),  inplace=True, crs=22092)

print(gdf)

Output:

    col1                        geometry
0  name1  POINT (554857.941 8728916.009)
Related Question