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