# Projection from Lambert Conformal Conic to Lat/Lon

**URL:** <https://discourse.julialang.org/t/projection-from-lambert-conformal-conic-to-lat-lon/68629>\
**Category:** Geo\
**Tags:** gmt, geodesy\
**Created:** [September 23, 2021, 12:40pm UTC](https://discourse.julialang.org/t/projection-from-lambert-conformal-conic-to-lat-lon/68629 "2021-09-23T12:40:28Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dieter](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dieter/32/29860_2.png) [@Dieter](https://discourse.julialang.org/u/Dieter)\
**Post date:** [September 23, 2021, 12:40pm UTC](https://discourse.julialang.org/t/projection-from-lambert-conformal-conic-to-lat-lon/68629/1 "2021-09-23T12:40:28Z")

</div>

Hello Community

After taking a look at packages like ArchGDAL I have still no idea how to project coordinates from an arbitrary Lambert Conformal Conic projection, defined by standard\_parallel, latitude\_of\_projection\_origin and longitude\_of\_central\_meridian, to geographical latitude / longitude coordinates.  
Unfortunately, there is no EPSG number available.

Is there a “function” like (lat,lon) = Lambert\_Conformal\_Conical\_to\_Lat\_Lon(standard\_parallel,latitude\_of\_projection\_origin,longitude\_of\_central\_meridian)?

If not, I would have to implement some equations like that [Link to equations](https://mathworld.wolfram.com/LambertConformalConicProjection.html)

Thanks for any replies, Dieter

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [September 23, 2021, 1:09pm UTC](https://discourse.julialang.org/t/projection-from-lambert-conformal-conic-to-lat-lon/68629/2 "2021-09-23T13:09:58Z")

</div>

Please check [this post using GMT](https://discourse.julialang.org/t/projecting-and-interpolating-data-to-a-regular-grid/56162/9).  
As your projection uses only one standard parallel, believe you have to set `lat_1` equal to `lat_2`.

It should be possible to do this also using proj4.jl

---

<div class="post-metadata">

**Author:** ![Dieter](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dieter/32/29860_2.png) [@Dieter](https://discourse.julialang.org/u/Dieter)\
**Post date:** [September 23, 2021, 1:13pm UTC](https://discourse.julialang.org/t/projection-from-lambert-conformal-conic-to-lat-lon/68629/3 "2021-09-23T13:13:59Z")

</div>

Thanks rafael.guerra

I have also seen this post but is GMT not only usable for ploting maps instead of converting points from one projection into another? But I will take a closer look at this post.

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [September 23, 2021, 1:16pm UTC](https://discourse.julialang.org/t/projection-from-lambert-conformal-conic-to-lat-lon/68629/4 "2021-09-23T13:16:55Z")

</div>

All numerical transformations should be available as arrays in GMT.  
Copying @joa-quim for expert advice.

NB:  
_Is the data from North America, Europe or some other region?_

---

<div class="post-metadata">

**Author:** ![Dieter](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dieter/32/29860_2.png) [@Dieter](https://discourse.julialang.org/u/Dieter)\
**Post date:** [September 23, 2021, 1:21pm UTC](https://discourse.julialang.org/t/projection-from-lambert-conformal-conic-to-lat-lon/68629/5 "2021-09-23T13:21:03Z")

</div>

The data is from Europe, this is the NetCDF output from the EuroCordex Gepotential Climate Forecast:

```julia
Lambert_Conformal standard_parallel 49.5                                                                      
Lambert_Conformal latitude_of_projection_origin 49.5                                                                      
Lambert_Conformal grid_mapping_name lambert_conformal_conic                                                   
Lambert_Conformal longitude_of_central_meridian 10.5                                                                      

```

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [September 23, 2021, 1:42pm UTC](https://discourse.julialang.org/t/projection-from-lambert-conformal-conic-to-lat-lon/68629/6 "2021-09-23T13:42:48Z")

</div>

We may need to collect a bit more info, [like provided here](https://www.researchgate.net/post/How_to_convert_data_with_a_Lambert_Conformal_Conic_projection), to define the right projection.

---

<div class="post-metadata">

**Author:** ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Post date:** [September 23, 2021, 1:54pm UTC](https://discourse.julialang.org/t/projection-from-lambert-conformal-conic-to-lat-lon/68629/7 "2021-09-23T13:54:11Z")

</div>

Off course GMT does it. Both `xy2lonlat` and `mapproject` will do the job but the latter has a more complicated manual (it does a lot more than coordinate conversions) that was not yet converted do .md (big job).

Just find the `proj4` string that defines Lambert data and follow the instructions of `xy2lonlat`

```julia
help?> xy2lonlat
search: xy2lonlat

  xy2lonlat(xy::Matrix{<:Real}, s_srs::String; t_srs=::String="+proj=longlat +datum=WGS84")

  or

  xy2lonlat(D::GMTdataset, s_srs::String; t_srs=::String="+proj=longlat +datum=WGS84")

  Computes the inverse projection from XY to LonLat in the given projection. The output is assumed to be in WGS84. If that isn't right, pass the
  appropriate projection info via the t_srs option.

  Parameters
  ––––––––––––

    • xy: The input data. It can be a Matrix, or a GMTdataset (or vector of it)

    • s_srs: The data projection system. This can be a PROJ4 or a WKT string

    • t_srs: The target SRS. If the default is not satisfactory, provide a new projection info (PROJ4 or WKT)

  Returns
  –––––––––

  A Matrix if input is a Matrix or a GMTdadaset if input had that type

```

---

<div class="post-metadata">

**Author:** ![visr](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/visr/32/17204_2.png) [@visr](https://discourse.julialang.org/u/visr)\
**Post date:** [September 23, 2021, 2:43pm UTC](https://discourse.julialang.org/t/projection-from-lambert-conformal-conic-to-lat-lon/68629/8 "2021-09-23T14:43:05Z")

</div>

Here is an example using Proj4.jl directly. Like GMT and ArchGDAL, which use PROJ as well, you can create the proj or WKT string yourself, see also the documentation here: [Lambert Conformal Conic — PROJ 9.1.0 documentation](https://proj.org/operations/projections/lcc.html).

```julia
using Proj4

lcc = "+proj=lcc +lon_0=-90 +lat_1=33 +lat_2=45"
trans = Proj4.Transformation(lcc, "EPSG:4326", always_xy=true)

julia> trans((0.0, 0.0))
2-element StaticArrays.SVector{2, Float64} with indices SOneTo(2):
 -90.0
   1.2722218725854067e-14

```

---

<div class="post-metadata">

**Author:** ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Post date:** [September 23, 2021, 2:54pm UTC](https://discourse.julialang.org/t/projection-from-lambert-conformal-conic-to-lat-lon/68629/9 "2021-09-23T14:54:57Z")

</div>

`xy2lonlat` && `lonlat2xy` use PROJ too 🙂 but using `EPSGs` is not implemented in those functions yet.

EDIT: which is silly because there is a `epsg2proj` function (probably added later)

```julia
julia> epsg2proj(4326)
"+proj=longlat +datum=WGS84 +no_defs"

```

---

<div class="post-metadata">

**Author:** ![Dieter](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dieter/32/29860_2.png) [@Dieter](https://discourse.julialang.org/u/Dieter)\
**Post date:** [September 23, 2021, 8:34pm UTC](https://discourse.julialang.org/t/projection-from-lambert-conformal-conic-to-lat-lon/68629/10 "2021-09-23T20:34:34Z")

</div>

Unfortunately, the NetCDF File does not contain more information as provided in

```julia
Lambert_Conformal standard_parallel 49.5                                                                      
Lambert_Conformal latitude_of_projection_origin 49.5                                                                      
Lambert_Conformal grid_mapping_name lambert_conformal_conic                                                   
Lambert_Conformal longitude_of_central_meridian 10.5                                                                      

```

---

<div class="post-metadata">

**Author:** ![Dieter](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dieter/32/29860_2.png) [@Dieter](https://discourse.julialang.org/u/Dieter)\
**Post date:** [September 23, 2021, 8:38pm UTC](https://discourse.julialang.org/t/projection-from-lambert-conformal-conic-to-lat-lon/68629/11 "2021-09-23T20:38:51Z")

</div>

Thanks joa-quim

```julia
xy2lonlat([-2825,-2825],"+proj=lcc +lat_1=49.5 +lat_2=49.5 +lat_0=49.5 +lon_0=10.5 +x_0=0 +y_0=0 +a=6371000 +units=km +no_defs",t_srs="+proj=longlat +datum=WGS84")

```

gives the correct result which is also identical to the self programmed set of equations:

```julia
function XY_Lambert_Conformal_Conical_2_Lat_Lon(x,y,λ0,ϕ0,ϕ1)
    
    R = 6371 # Radius of Earth

    λ0_rad = λ0*π/180
    ϕ0_rad = ϕ0*π/180
    ϕ1_rad = ϕ1*π/180

    x_skaliert = x/R
    y_skaliert = y/R

    n = sin(ϕ1_rad)

    F = (cos(ϕ1_rad)*(tan(π/4 + ϕ1_rad/2))^n)/n
    ρ0 = F*(cot(π/4 + ϕ0_rad/2))^n

    θ = atan(x_skaliert/(ρ0 - y_skaliert))
    ρ = sign(n)*sqrt(x_skaliert^2 + (ρ0 - y_skaliert)^2)

    ϕ_rad = 2atan((F/ρ)^(1/n)) - π/2
    λ_rad = λ0_rad + θ/n

    ϕ = ϕ_rad*180/π
    λ = λ_rad*180/π

    return λ,ϕ

end

```
