Translates a geometry by the specified delta values, then scales the result by the specified factors. Returns a new geometry object.
Syntax
geometry ST_TransScale(geometry geomA, float deltaX, float deltaY, float xFactor, float yFactor);Parameters
| Parameter | Description |
|---|---|
| geomA | The geometry object to transform. |
| deltaX | The translation offset applied to the x coordinates. |
| deltaY | The translation offset applied to the y coordinates. |
| xFactor | The scale factor applied to the x coordinates after translation. |
| yFactor | The scale factor applied to the y coordinates after translation. |
Description
ST_TransScale applies two transformations in sequence: translation first, then scaling. It shifts the x and y coordinates by deltaX and deltaY, then multiplies the translated result by xFactor and yFactor. Because translation happens before scaling, the delta values are also multiplied by the scale factors in the final coordinates.
The function operates on 2D coordinates (x and y) only. For 3D geometries, z coordinates are passed through unchanged. Circular strings and curves are supported.
Examples
The following example translates a 2D LINESTRING by (1, 1), then scales by factors of (2, 2).
SELECT ST_AsEWKT(ST_TransScale(ST_GeomFromText('LINESTRING(2 1,1 1)',4326),1,1,2,2));
st_asewkt
-------------------------------
SRID=4326;LINESTRING(6 4,4 4)
(1 row)The coordinates are computed as: x' = xFactor * (x + deltaX) and y' = yFactor * (y + deltaY). For the first point: x' = 2 * (2 + 1) = 6, y' = 2 * (1 + 1) = 4.
See also
ST_Affine: applies a full affine transformation in 3D
ST_Translate: translates a geometry by the specified offsets without scaling
ST_Scale: scales a geometry by the specified factors without translation