Home » Software » PostGIS: Spatially enabled Relational Database Sytem » Affine Transformation Operations in PostGIS

# Affine Transformation Operations in PostGIS

**Overview**

The `ST_Affine()`function from PostGIS is useful for manipulating geometries, but requires the elements of a transformation matrix. This page documents progress on automating the computation of the transformation matrix by least-squares (Bruce Rindahl) via SQL. This would allow a pure PostGIS solution to computing and applying affine transformations to geometry data.

**An open-source algorithm for computing the transformation matrix**

Example code from GRASS (v.transform) was used as a template.

**Approach**

Compute transformation matrix based on a table of control points, stored as numbers.

**Evaluation of results**

Comparable to output from a similar analysis done in R, and the original algorithm as implemented in `v.transform` (GRASS).

## Software

- General Purpose Programming with Scripting Languages
- LaTeX Tips and Tricks
- PostGIS: Spatially enabled Relational Database Sytem
- PROJ: forward and reverse geographic projections
- GDAL and OGR: geodata conversion and re-projection tools
- R: advanced statistical package
- GRASS GIS: raster, vector, and imagery analysis
- Generic Mapping Tools: high quality map production