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
| Parameter | Description |
|---|---|
| g1 | The geometry object to translate. |
| deltax | The offset along the x-axis. |
| deltay | The offset along the y-axis. |
| deltaz | The 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)该文章对您有帮助吗?