pyproj

3.7.2 · active · verified Sun Mar 29

pyproj is a Python interface to PROJ, a powerful C library for cartographic projections and coordinate transformations. It enables precise coordinate reference system (CRS) operations, geodesic computations, and transformation between different spatial reference systems with high accuracy and comprehensive EPSG support. The library is actively maintained with frequent releases, currently at version 3.7.2.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to perform a basic coordinate transformation from WGS84 geographic coordinates (longitude, latitude) to UTM Zone 33N projected coordinates (easting, northing) using `pyproj.CRS` to define the coordinate systems and `pyproj.Transformer` for the transformation. The `always_xy=True` parameter ensures a consistent (x, y) or (longitude, latitude) axis order.

from pyproj import CRS, Transformer

# Define source and target Coordinate Reference Systems (CRSs)
wgs84 = CRS('EPSG:4326')  # WGS84 Geographic CRS (longitude, latitude)
utm_zone_33n = CRS('EPSG:32633') # UTM Zone 33N Projected CRS (easting, northing)

# Create a transformer, ensuring consistent axis order (x, y / lon, lat)
transformer = Transformer.from_crs(wgs84, utm_zone_33n, always_xy=True)

# Define a point in WGS84 (longitude, latitude)
lon, lat = 10.0, 60.0

# Transform the point
x, y = transformer.transform(lon, lat)

print(f"Original WGS84 (lon, lat): ({lon}, {lat})")
print(f"Transformed UTM Zone 33N (easting, northing): ({x:.2f}, {y:.2f})")

# Transform multiple points
points_wgs84 = [(10.0, 60.0), (11.0, 61.0), (12.0, 62.0)]
transformed_points_utm = list(transformer.itransform(points_wgs84))

print(f"Transformed multiple points: {transformed_points_utm}")

view raw JSON →