0

Currently, I am trying to convert (lat, long) into (x, y) coordinates in Python. There are some packages like pyproj or utm to do that. For example:

import utm
lat = 41.8836718276551
lon = 12.4877775603346
x, y, zn, zl = utm.from_latlon(float(lat), float(lon))

My question is that what is the order of the parameter? is it (lat, lon) or (lon, lat)? Even If I use pyproj to do the same conversion, then what will be the order?

1
  • The source has def from_latlon(latitude, longitude, force_zone_number=None, force_zone_letter=None): Note that using 'long' as a variable name is fraught (type name) -- use 'lon' or 'longitude' instead.
    – Vince
    Apr 22, 2020 at 20:37

1 Answer 1

4

For pyproj you should be mindful of axis order changes.

If you want it to always be in the lon, lat order, you should specify it when creating the transformer.

For example:

from pyproj import Transformer
transformer = Transformer.from_crs(..., ..., always_xy=True)

Otherwise, you should inspect the axis order of your CRS as shown in the getting started documentation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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