# How to convert lat/lon to x/y in Lambert conformal conic projection using Python

I am trying to convert some lat and lon to x and y with projection Lambert conformal conic. I am trying the Python package `pyproj` for that but getting the wrong values. The issue is that the coordinate reference system is not available in EPSG codes, I built a custom CRS based on the details here. I think that's where I am doing something wrong.

Below is the code I tried-

``````import pyproj

proj_daymet = "+proj=lcc +lat_0=42.5 +lon_0=-100 +lat_1=25 +lat_2=60 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs" #my custom CRS

geog_crs = pyproj.crs.GeographicCRS()

lat = 31.177685
lon = -87.103554

# the transform command below gives incorrect values

pyproj.transform(geog_crs,proj_daymet , lat, lon)

# it outputs: 87465941.89322367, 6696423.32671964, the correct answer is 1192729, 1114943
``````

The arguments for transform is `lon` first then `lat`. Also, `transform` method is deprecated, instead you can use the following

``````import pyproj

proj_daymet = "+proj=lcc +lat_0=42.5 +lon_0=-100 +lat_1=25 +lat_2=60 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs" #my custom CRS

lat = 31.177685
lon = -87.103554

pyproj.Proj(proj_daymet)(lon, lat)

# output: (1192750.1882841575, -1114999.8438182664)
``````
• Thanks, it worked. Just needed to switch the lat and lon. Aug 19, 2022 at 15:54
• The Transformer is preferred in most scenarios. For more details: pyproj4.github.io/pyproj/stable/… Aug 19, 2022 at 16:41

The issue you are running into is the axis order of your CRS. That determines the order if the input to transform.

`GeographicCRS` is ordered lon, lat whereas "EPSG:4326" is ordered, lat,lon.

You can also add the `always_xy=True` to make force it to be lon,lat.

``````from pyproj import Transformer
proj_daymet = "+proj=lcc +lat_0=42.5 +lon_0=-100 +lat_1=25 +lat_2=60 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs" #my custom CRS
transformer = Transformer.from_crs("EPSG:4326", proj_daymet)
lat = 31.177685
lon = -87.103554
transformer.transform(lat, lon)
``````
``````(1192750.1882841575, -1114999.8438182664)
``````