Scales a geometry object to a new size by multiplying its coordinate values by the corresponding factors.
Syntax
geometry ST_Scale(geometry geomA, float xFactor, float yFactor, float zFactor);
geometry ST_Scale(geometry geomA, float xFactor, float yFactor);
geometry ST_Scale(geometry geom, geometry factor);
geometry ST_Scale(geometry geom, geometry factor, geometry origin);Parameters
| Parameter | Description |
|---|---|
| geomA/geom | The geometry object to scale. |
| xFactor | The scaling factor for x coordinate values. |
| yFactor | The scaling factor for y coordinate values. |
| zFactor | The scaling factor for z coordinate values. |
| factor | The scaling factor as a geometry point. Accepts 2D, 3DM, 3DZ, or 4D point objects, which sets the scaling factor for all supported dimensions. |
| origin | The origin point of the scaling operation. |
Description
If
xFactor,yFactor, orzFactoris not specified, scaling is not applied to the corresponding dimension.Supports circular strings, curves, polyhedral surfaces, triangles, triangulated irregular network (TIN) surfaces, and 3D objects.
Supports geometry objects that contain m coordinates.
If
originis specified, the function scales the geometry object in place relative to that origin — for example, using the centroid of the geometry object. Iforiginis not specified, the function scales the geometry object relative to the actual origin by multiplying each coordinate value by its corresponding factor.
Examples
Scale a geometry object using scalar x and y factors.
SELECT ST_AsText(ST_Scale('LINESTRING(2 1,1 1)'::geometry,2,2));
st_astext
---------------------
LINESTRING(4 2,2 2)
(1 row)Scale a geometry object using the factor geometry parameter.
SELECT ST_AsText(ST_Scale('LINESTRING(2 1,1 1)'::geometry,'POINT(2 2)'::geometry));
st_astext
---------------------
LINESTRING(4 2,2 2)
(1 row)Scale a geometry object with and without an origin parameter, and compare the results.
SELECT
ST_Scale(g,factor),
ST_Scale(g,factor,'POINT(2 1)'::geometry),g
from (select 'LINESTRING(2 1,1 1,1 2)'::geometry as g,'POINT(3 3)'::geometry as factor) as t;