Functions / PostGIS / ST_RotateY
PostGISAffine Transformations

ST_RotateY

What is ST_RotateY?

ST_RotateY is a PostGIS function that rotates a geometry about the Y axis by the given angle in radians. Y coordinates are unchanged; X and Z are rotated in the XZ plane.

SQL
ST_RotateY(geometry geomA, float rotRadians)geometry

Equivalent to ST_Affine(geom, cos(θ), 0, sin(θ), 0, 1, 0, -sin(θ), 0, cos(θ), 0, 0, 0).

When would you use ST_RotateY?

Use ST_RotateY in 3D workflows — tilting a building model sideways, adjusting the pitch of a 3D mesh, or composing orientation transforms in CAD/BIM pipelines. It is rarely needed for 2D mapping.

SQL
SELECT ST_RotateY(geom, radians(15)) FROM solar_panels;

FAQs

How does ST_RotateY compare with ST_RotateX and ST_RotateZ?

Each is the rotation about the named axis. ST_RotateY changes X and Z; ST_RotateX changes Y and Z; ST_RotateZ changes X and Y. Compose them to reach any 3D orientation.

What angle sign convention does it use?

Right-hand rule: positive angles rotate counter-clockwise when looking back along the +Y axis. Use negative values or -rotRadians to flip direction.

Will it modify my 2D geometry?

A 2D input with Z = 0 will gain a Z component after rotation, becoming 3D. If you want to stay in 2D, rotate about the Z axis instead.

Can I combine with ST_Translate for rotation about a line?

Yes. Translate so the desired axis passes through the origin, apply ST_RotateY, then translate back. This idiom is standard in 3D transform code.