I'm working on a project that needs one set of coordinates converted to another(from CRS 229 to CRS 3857), and I have a function that works when you put the former coordinates in, but I would like to make it so that I can just run the function over the entire column(s)(there are X, Y, and a XY column).
This is what the code looks like
from pyproj import Proj, transform, CRS, Transformer
import pandas as pd
import geopandas as gpd
crs_2229 = CRS.from_epsg(2229)
crs_3857 = CRS.from_epsg(3857)
transformer = Transformer.from_crs(crs_2229, crs_3857)
data = {'X': [6481427.400, 6485873.280],
'Y': [1797333.200, 1796834.811],
'XY':[(6481427.400000006,1797333.200000003),(6485873.279835222,1796834.811359349)]}
df = pd.DataFrame(data)
Now if I run this
transformer.transform(6481427.400000006,1797333.200000003)
It comes with the correct transformation of (-13165144.971136427, 4019524.5726486626). But how do I make it a little more automated?
Tried a lambda function, but it kept on rising as a key value error. Tried to make a for loop, but that didn't give me anything. Searched online for functions, but they didn't work on it, and now with the google colabs AI tool, it gave me the same code I would try as suggestions but they never worked.