ST_Translate

更新时间:
复制 MD 格式

Returns a new geometry object with coordinates shifted by the specified offsets.

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 along the x-axis.
deltayThe offset along the y-axis.
deltazThe offset along the z-axis.

Description

  • Offset values use the units defined by the spatial reference identifier (SRID) of the input geometry.

  • Supports 3D objects and preserves z coordinates.

  • Supports circular strings and curves.

Examples

Translate a 2D linestring

Shift a LINESTRING 1 unit along both the x-axis and y-axis using SRID 4326 (WGS 84 degrees):

SELECT ST_AsEWKT(ST_Translate(ST_GeomFromText('LINESTRING(2 1,1 1)',4326),1,1));
           st_asewkt
-------------------------------
 SRID=4326;LINESTRING(3 2,2 2)
(1 row)