PostGISAffine Transformations

ST_TransScale

What is ST_TransScale?

ST_TransScale is a PostGIS function that applies a translation followed by a scale in a single call. Each vertex becomes x' = (x + deltaX) * xFactor, y' = (y + deltaY) * yFactor.

SQL
ST_TransScale(geometry geomA, float deltaX, float deltaY, float XFactor, float YFactor)geometry

It is equivalent to ST_Scale(ST_Translate(geom, deltaX, deltaY), XFactor, YFactor) but written as one operation.

When would you use ST_TransScale?

Use ST_TransScale when you have a coordinate-system conversion that involves an offset and a linear scaling in a single step — converting from a local CAD origin to world coordinates, implementing a normalise-then-stretch step, or writing compact affine pipelines. It is slightly faster and more concise than chaining separate calls.

SQL
1-- Offset by (100, 200) and enlarge by 1.5x:
2SELECT ST_TransScale(geom, 100, 200, 1.5, 1.5) FROM cad_drawings;

FAQs

What order are the operations applied in?

Translate first, then scale. Note that this means the translation itself gets scaled — if you want scale-then-translate, compose calls explicitly: ST_Translate(ST_Scale(geom, …), …). The order matters and changes the output.

Why not just use ST_Translate + ST_Scale?

Functionally identical, but ST_TransScale is a single expression and slightly faster because PostGIS applies both steps in one vertex sweep. For bulk transforms on millions of geometries the saving can be measurable.

Does it support Z or 3D transforms?

No — ST_TransScale is 2D only. For 3D transforms combining translate and scale, reach for ST_Affine and supply the full matrix.

What are the units of the parameters?

The offsets are in SRID units; the factors are unitless ratios. As with ST_Scale, negative factors mirror the geometry after translation.