ST_Rotate
Name
ST_Rotate — Rotates a geometry about an origin point.
Synopsis
geometry
ST_Rotate
(
geometry
geomA
, float
rotRadians
)
;
geometry
ST_Rotate
(
geometry
geomA
, float
rotRadians
, float
x0
, float
y0
)
;
geometry
ST_Rotate
(
geometry
geomA
, float
rotRadians
, geometry
pointOrigin
)
;
Description
Rotates geometry rotRadians counter-clockwise about the origin point. The rotation origin can be specified either as a POINT geometry, or as x and y coordinates. If the origin is not specified, the geometry is rotated about POINT(0 0).
Enhanced: 2.0.0 support for Polyhedral surfaces, Triangles and TIN was introduced.
Enhanced: 2.0.0 additional parameters for specifying the origin of rotation were added.
Availability: 1.1.2. Name changed from Rotate to ST_Rotate in 1.2.2
This function supports 3d and will not drop the z-index.
This method supports Circular Strings and Curves
This function supports Polyhedral surfaces.
This function supports Triangles and Triangulated Irregular Network Surfaces (TIN).
Examples
--Rotate 180 degrees SELECT ST_AsEWKT(ST_Rotate('LINESTRING (50 160, 50 50, 100 50)', pi())); st_asewkt --------------------------------------- LINESTRING(-50 -160,-50 -50,-100 -50) (1 row) --Rotate 30 degrees counter-clockwise at x=50, y=160 SELECT ST_AsEWKT(ST_Rotate('LINESTRING (50 160, 50 50, 100 50)', pi()/6, 50, 160)); st_asewkt --------------------------------------------------------------------------- LINESTRING(50 160,105 64.7372055837117,148.301270189222 89.7372055837117) (1 row) --Rotate 60 degrees clockwise from centroid SELECT ST_AsEWKT(ST_Rotate(geom, -pi()/3, ST_Centroid(geom))) FROM (SELECT 'LINESTRING (50 160, 50 50, 100 50)'::geometry AS geom) AS foo; st_asewkt -------------------------------------------------------------- LINESTRING(116.4225 130.6721,21.1597 75.6721,46.1597 32.3708) (1 row)