ST_Translate

更新时间:
复制 MD 格式

Returns a new geometry object by offsetting its coordinates along the x, y, and optionally z axes.

Syntax

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

Parameters

ParameterDescription
g1The geometry object to translate.
deltaxThe offset distance along the x axis.
deltayThe offset distance along the y axis.
deltazThe offset distance along the z axis. Only used in the 3D overload.

Usage notes

  • Offset distances are measured in the units defined by the spatial reference identifier (SRID) of the geometry object.

  • ST_Translate preserves z coordinates and supports 3D objects.

  • ST_Translate supports circular strings and curves.

Examples

Translate a 2D LINESTRING by 1 unit along both axes:

SELECT ST_AsEWKT(ST_Translate(ST_GeomFromText('LINESTRING(2 1,1 1)', 4326), 1, 1));

Output:

           st_asewkt
-------------------------------
 SRID=4326;LINESTRING(3 2,2 2)
(1 row)