Skip to content

Instantly share code, notes, and snippets.

@SofianeHamlaoui
Created July 18, 2023 09:15
Show Gist options
  • Save SofianeHamlaoui/1ec52273b25c4e5ee9dd2610f5b587ce to your computer and use it in GitHub Desktop.
Save SofianeHamlaoui/1ec52273b25c4e5ee9dd2610f5b587ce to your computer and use it in GitHub Desktop.
Converting EPSG 4326 to EPSG 2154 using X,Y,Z
def convert_coordinates(x, y, z):
src_crs = pyproj.CRS.from_epsg(4326)
dest_crs = pyproj.CRS.from_epsg(2154)
transformer = pyproj.Transformer.from_crs(src_crs, dest_crs, always_xy=True)
# Perform the transformation
dest_x, dest_y, dest_z = transformer.transform(x, y, z)
return dest_x, dest_y, dest_z
x = 4.858116239
y = 45.764353552
z = 169.06286470
dest_x, dest_y, dest_z = convert_coordinates(x, y, z)
print(f"Converted Coordinates (EPSG 2154): {dest_x}, {dest_y}, {dest_z}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment