How to convert a point from a given 2D crs to another one

I thought it would be easy, but I can’t find a way to programmatically convert (and extract the X,Y values) a 2D point from a given well known reference point to another one.

For example, I have a point in “EPSG:4326”, the geographical coordinates system of the WGS 84 ellipsoid, and I want it in “EPSG:3035” (projected with metric unit).

So Paris (lon 2.35, lat: 48.85) would become X: 3760537, Y: 2888771

I have tried Proj4.transform but it applies to points that have been created with the Projection constructor that in turn uses some string format I don’t understand.

Does the README of Proj.jl, or the topic Converting UK National Grid to Lat Lon and vice versa help with their examples?

1 Like

Yes, at the end…

using Proj
trans = Proj.Transformation("EPSG:4326", "EPSG:3035", always_xy=true)
(X,Y) = trans(2.35,48.85)

My issue is that for the first time I started by asking ChatGPT (paid version) and it sent me completely out of course with old packages and not working code that I tried to debug… I lost many hours, what a lesson…

If you seek a native Julia solution, take a look into CoordRefSystems.jl

2 Likes

It seems the requested CRS EPSG:3035 is not yet supported? But maybe I’m doing something wrong.

julia> CoordRefSystems.get(EPSG{3035})
ERROR: MethodError: no method matching get(::Type{EPSG{3035}})

Didnt check. It may be just a missing method in the CoordRefSystems.get function. It points to the correct CRS type in the epsg.io catalogue:

CoordRefSystems.jl already supports most (if not all practical) projections from PROJ.

Ah, I think I misunderstood the type of projection you’re referring to. Since this is off-topic, I’ve made an issue.