pyproj

raw JSON →
3.7.2 verified Tue May 12 auth: no python install: verified

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.

pip install pyproj
error ModuleNotFoundError: No module named 'pyproj'
cause The pyproj library is not installed in your current Python environment.
fix
pip install pyproj
error DeprecationWarning: `transform` is deprecated. Use `pyproj.Transformer.from_crs` instead.
cause The direct `pyproj.transform()` function is deprecated in pyproj 2.x and 3.x; the recommended approach is to use `pyproj.Transformer.from_crs()` for better control and performance.
fix
Replace pyproj.transform(crs_from, crs_to, x, y) with transformer = pyproj.Transformer.from_crs(crs_from, crs_to, always_xy=True); x2, y2 = transformer.transform(x, y).
error pyproj.exceptions.CRSError: Invalid projection string: +init=epsg:4326
cause The `+init=` syntax for defining a CRS is deprecated and no longer directly supported by the underlying PROJ library in modern `pyproj` versions, leading to an invalid string error.
fix
Replace deprecated +init=epsg:XXXX with the modern EPSG:XXXX string when defining CRSs (e.g., pyproj.CRS('EPSG:4326')).
error NameError: name 'Proj' is not defined
cause In pyproj versions 2.x and later, the `Proj` class is not automatically imported into the top-level `pyproj` namespace and its functionality is largely superseded by `CRS` and `Transformer`.
fix
For CRS definitions, use pyproj.CRS(). For transformations, use pyproj.Transformer.from_crs(). If Proj is strictly needed, import it explicitly with from pyproj import Proj.
breaking Minimum Python version required for pyproj has increased significantly in recent 3.x releases. For pyproj 3.7.2, Python 3.11 or newer is required.
fix Upgrade your Python environment to 3.11 or newer, or use an older pyproj version compatible with your Python version. (e.g., pyproj 3.6.0 for Python 3.9+, pyproj 3.7.0 for Python 3.10+).
breaking Minimum PROJ C library version required for pyproj has increased. For pyproj 3.7.2, PROJ 9.4 or newer is required.
fix Ensure your system's PROJ installation meets the minimum requirement (PROJ 9.4+). If installing via pip, wheels often bundle PROJ, but if building from source or using conda, verify your PROJ version.
deprecated The `pyproj.Proj` class is considered a legacy interface. Its `init` keyword for initialization is deprecated.
fix Migrate to `pyproj.CRS` for defining Coordinate Reference Systems and `pyproj.Transformer` for performing transformations. For example, instead of `Proj(init='epsg:4326')`, use `CRS('EPSG:4326')` and `Transformer.from_crs()`.
gotcha pyproj 3.x wheels no longer include transformation grids by default. These grids are crucial for certain high-accuracy datum transformations (e.g., NAD27 to NAD83).
fix You may need to manually manage PROJ's data directory or install transformation grid packages separately. Consult the pyproj documentation on 'Transformation Grids' for guidance.
gotcha When performing transformations, the axis order (e.g., longitude/latitude vs. latitude/longitude, or easting/northing vs. northing/easting) can be a source of confusion. By default, PROJ might use different axis orders based on CRS definition.
fix Always use `always_xy=True` when creating a `Transformer` instance to ensure consistent (x, y) or (longitude, latitude) input and output order, which aligns with common GIS conventions.
breaking The default value for `return_back_azimuth` in `fwd_intermediate` and `inv_intermediate` methods of `pyproj.Geod` changed from `False` to `True` to match `fwd` and `inv` methods.
fix If your code relies on the previous default behavior, explicitly set `return_back_azimuth=False` when calling `fwd_intermediate` or `inv_intermediate`.
conda install -c conda-forge pyproj
python os / libc status wheel install import disk
3.10 alpine (musl) wheel - 0.21s 49.7M
3.10 alpine (musl) - - 0.22s 49.7M
3.10 slim (glibc) wheel 2.0s 0.16s 49M
3.10 slim (glibc) - - 0.15s 49M
3.11 alpine (musl) wheel - 0.29s 52.7M
3.11 alpine (musl) - - 0.32s 52.7M
3.11 slim (glibc) wheel 2.0s 0.27s 52M
3.11 slim (glibc) - - 0.25s 52M
3.12 alpine (musl) wheel - 0.24s 44.8M
3.12 alpine (musl) - - 0.25s 44.8M
3.12 slim (glibc) wheel 1.9s 0.25s 44M
3.12 slim (glibc) - - 0.25s 44M
3.13 alpine (musl) wheel - 0.22s 44.4M
3.13 alpine (musl) - - 0.23s 44.3M
3.13 slim (glibc) wheel 1.8s 0.24s 44M
3.13 slim (glibc) - - 0.23s 44M
3.9 alpine (musl) build_error - - - -
3.9 alpine (musl) - - - -
3.9 slim (glibc) wheel 2.2s 0.17s 45M
3.9 slim (glibc) - - 0.16s 45M

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}")