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).