This topic describes the ST_Scale function. This function scales a geometry object to a new size by multiplying its coordinate values with 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 that you want to specify. |
xFactor | The factor for the values of the x coordinate. |
yFactor | The factor for the values of the y coordinate. |
zFactor | The factor for the values of the y coordinate. |
factor | The scaling factor. |
origin | The origin of the scaling. |
Description
- You can specify the factor parameter to a 2D, 3DM, 3DZ, or 4D point object. This configuration ensures the scaling factor for all supported dimensions. If the xFactor, yFactor, or zFactor parameter is not specified, the scaling is not performed on the corresponding dimension of the geometry object.
- This function supports circular strings, curves, polyhedral surfaces, triangles, triangulated irregular network (TIN) surfaces, and 3D objects.
- This function supports geometry objects that contain m coordinates.
- If you specify the origin parameter, the ST_Scale function immediately scales the geometry object in place. For example, you can specify the centroid of the geometry object as the scaling origin. If you do not specify the origin parameter, the ST_Scale function scales the geometry object relative to the actual origin of the geometry object. In this case, this function scales the geometry object by multiplying coordinate values by the values of the corresponding factor parameters.
Examples
- Scales a geometry object by using the default parameter settings.
SELECT ST_AsText(ST_Scale('LINESTRING(2 1,1 1)'::geometry,2,2)); st_astext --------------------- LINESTRING(4 2,2 2) (1 row)
- Scales a geometry object by specifying the factor 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)
- Scales a geometry object by specifying the origin parameter.
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;