Name

ST_Translate — Translates a geometry by given offsets.

Synopsis

geometry ST_Translate(geometry g1, float deltax, float deltay);

geometry ST_Translate(geometry g1, float deltax, float deltay, float deltaz);

Description

Returns a new geometry whose coordinates are translated delta x,delta y,delta z units. Units are based on the units defined in spatial reference (SRID) for this geometry. M coordinates are preserved.

[Note]

Prior to 1.3.4, this function crashes if used with geometries that contain CURVES. This is fixed in 1.3.4+

Availability: 1.2.2

This function supports 3d and will not drop the z-index.

This method supports Circular Strings and Curves.

This function supports M coordinates.

Examples

Move a point 1 degree longitude

Code
SELECT ST_Translate(ST_GeomFromText('POINT(-71.01 42.37)', 4326), 1, 0) AS wgs_transgeomtxt;
Output
POINT(-70.01 42.37)

Move a linestring 1 degree longitude and 1/2 degree latitude

Code
SELECT ST_Translate(ST_GeomFromText('LINESTRING(-71.01 42.37,-71.11 42.38)', 4326), 1, 0.5) AS wgs_transgeomtxt;
Output
LINESTRING(-70.01 42.87,-70.11 42.88)
Figure
Geometry figure for visual-st-translate-02

Move a 3d point

Code
SELECT ST_Translate(CAST('POINT(0 0 0)' AS geometry), 5, 12, 3);
Output
POINT(5 12 3)

Move points with a measure coordinate

Code
SELECT ST_Translate('POINTM(0 0 11)', 5, 12);
Output
POINTM(5 12 11)
Figure
Geometry figure for visual-st-translate-04
Code
SELECT ST_Translate('POINT(0 0 7 11)', 5, 12, 3);
Output
POINT(5 12 10 11)

Move a curve and a point

Code
SELECT ST_Translate(ST_Collect('CURVEPOLYGON(CIRCULARSTRING(4 3,3.12 0.878,1 0,-1.121 5.1213,6 7,8 9,4 3))', 'POINT(1 3)'), 1, 2);
Output
GEOMETRYCOLLECTION(CURVEPOLYGON(CIRCULARSTRING(5 5,4.12 2.878,2 2,-0.121 7.1213,7 9,9 11,5 5)), POINT(2 5))
Figure
Geometry figure for visual-st-translate-06