I am trying to project regular WGS84 coordinates to a local projected system (Azimuthal Equidistant), using meters and centered on the eiffel tower (as an exemple). I am using python 3.8.2 and pyproj 2.4.1 for that.

I tried to reproduce the method of Spacedman from [this post], but the results I get are clearly wrong ...

Here is my test code, trying to get the coordinates of Le Louvre Museum in that system :

# coding: utf8
import pyproj

def to_local(lon_angle, lat_angle, origin):
  crs_wgs84 = pyproj.Proj('epsg:4326') # WGS84 input projection (angle)
  crs_aeqd = pyproj.Proj(proj='aeqd', datum='WGS84', lon_0=origin[0], lat_0=origin[1], units='m') # Local Azimuthal Equidistant projection, centered on the 'origin' parameter
  x, y = pyproj.transform(crs_wgs84, crs_aeqd, lon_angle, lat_angle)
  return(x, y)

origin = (2.294473, 48.858440) # Eiffel tower in Paris
destination = (2.335769, 48.861062) # Le Louvre Museum

x, y = to_local(destination[0], destination[1], origin)
print(f'In local system centred on origin, destination has coordinates ({x}, {y})') # Result, in meters, should be around (3030, 290)

From what I roughly computed manually, I should get something like 3030 meters as longitude and 290 meters as latitude, both positive since Le Louvre is North-West from the Eiffel Tower, but here is the output :

> In local system centred on origin, destination has coordinates (5635219.051216577, -3788748.14149113)

I don't understand thoses values, what am I missing here ?

  • 3
    is your WGS84 lat/lon not lon/lat maybe?
    – Ian Turton
    Apr 1 '20 at 15:55
  • 1
    I tried your conversion with cs2cs, and I got 3030.09809, 292.40716 , but when I reverse the lon/lat of the destination, I get the same result as you do which is 5635219.05122, -3788748.14149. Looks like some kind of reversal of lat/lon occurs somewhere indeed...
    – FSimardGIS
    Apr 1 '20 at 21:48
  • please answer your question with an answer not by editing your question
    – Ian Turton
    Apr 2 '20 at 12:59

Here is a link to a related pyproj issue: https://github.com/pyproj4/pyproj/issues/538

Here is a link to more information about the axis order changes: https://pyproj4.github.io/pyproj/stable/gotchas.html#axis-order-changes-in-proj-6

In summary, you need to either be aware of your axis order on input/output or use the always_xy=True when creating the pyproj.Transformer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.