--- id: affine version: "3.0.0" license: unclear license_treatment: permissive maintenance: active --- # affine — Matrices describing affine transformation of the plane License: permissive · Maintenance: active · Downloads: 5.5M/mo ## What it is and what it does Affine is a lightweight library for working with 2D affine transformation matrices. It provides a single core class that represents the 3x3 augmented matrix used to describe transformations like translation, rotation, scaling, and shearing in two dimensions. You construct transformations either by passing raw matrix coefficients or by using convenience class methods (identity, translation, scale, rotation, shear), then apply them to coordinate tuples using the * operator or combine multiple transformations by multiplying matrices together. The package is particularly useful in geospatial and raster imaging workflows, where affine transformations map pixel coordinates to real-world coordinates. It includes a from_gdal() method to convert GDAL GeoTransform tuples (the standard format used by geospatial libraries) into Affine objects, and supports computing inverse transformations with the ~ operator. With only attrs as a runtime dependency and a pure-Python wheel, it installs with minimal friction. Use it for: - Convert pixel coordinates to world coordinates in georeferenced raster datasets using GDAL GeoTransform data - Compose multiple geometric transformations (rotation, translation, scaling) into a single matrix for efficient batch application - Compute inverse transformations to map world coordinates back to image space in GIS workflows - Represent and apply 2D coordinate transformations in graphics or image processing pipelines - Build geospatial tools that need to work with standard affine transformation matrices from GDAL or similar libraries ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Affine provides a Python class for representing and manipulating 2D affine transformation matrices, with support for translation, rotation, scaling, and shearing operations. Yes. Affine is a stable, actively maintained library (Production/Stable status, released 6 days ago) with no known vulnerabilities, minimal dependencies, and a clear use case in geospatial and graphics work. The permissive license and Python 3.9+ support make it safe to adopt. Install it if you work with georeferenced rasters, need to compose 2D transformations, or integrate with GDAL-based tools. ## Install pip install affine uv add affine poetry add affine ## Installing affine Before you install: Low friction: pure Python wheel with a single lightweight dependency (attrs). Active maintenance with a recent release (6 days old) and steady repository activity. License in practice: Permissive license allows use in commercial and open-source projects without significant restrictions. Quickstart: from affine import Affine # Create a translation transformation transform = Affine.translation(1.0, 5.0) # Apply to coordinates result = transform * (1.0, 1.0) print(result) # (2.0, 6.0) # Combine transformations combined = Affine.translation(1.0, 5.0) * Affine.rotation(45.0) Requires Python 3.9 or later. Verify before relying: - Whether the package provides inverse transformation computation beyond the ~ operator shown in examples - Performance characteristics when applying transformations to large coordinate arrays - Support for 3D affine transformations or whether it is strictly 2D ## Package facts - License: not declared (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 5.5M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags 2d affine transformation matrix, coordinate transformation, image to world coordinates, gdal geotransform, geometric transformation, matrix multiplication, raster georeferencing, geospatial, matrix-math, coordinate-transform [View on SkillFed](https://skillfed.io/packages/affine) · [View on PyPI](https://pypi.org/project/affine/)