How to Convert Lambert 93 Coordinates to Longitude and Latitude with Python?

Introduction

The Lambert 93 projection system is a conformal conic projection widely used in France for mapping purposes. However, for more universal use, it's often necessary to convert these coordinates into longitude and latitude using the WGS 84 system (EPSG:4326). To do this, we use the pyproj library, which allows conversion between different spatial reference systems.

Installing pyproj

If pyproj is not yet installed, you can install it using pip:

1
pip install pyproj

Or with Anaconda:

1
conda install -c conda-forge pyproj

Converting Lambert 93 Coordinates to Latitude and Longitude

Here is an updated example using the recommended method from pyproj:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
from pyproj import Transformer

# Create a transformer object between EPSG:2154 (Lambert 93) and EPSG:4326 (WGS 84)
transformer = Transformer.from_crs("EPSG:2154", "EPSG:4326", always_xy=True)

# Lambert 93 coordinates
x1, y1 = 882408.3, 6543019.6

# Convert to longitude and latitude
longitude, latitude = transformer.transform(x1, y1)

# Display results
print(longitude, latitude)

Output:

1
5.355651287573366 45.96240165432614

Code Explanation:

  1. Use of Transformer.from_crs: This method replaces Proj and transform, which are deprecated in recent versions of pyproj.
  2. Parameter always_xy=True: Ensures the coordinate order is (x, y) (i.e., longitude, latitude), unlike some projections that reverse the order.
  3. Conversion with transformer.transform(x, y): Applies the transformation to the given point.

Finding EPSG Codes

EPSG codes are standardized identifiers for spatial reference systems. Here are some useful references:

References