This topic describes the ST_SwapOrdinates function. This function swaps the specified coordinates of a geometry object.

Syntax

geometry  ST_SwapOrdinates(geometry  geom , cstring  ords);

Parameters

Parameter Description
geom The geometry object that you want to specify.
ords The coordinates that you want to swap. The value of this parameter is a 2-character string. Valid values: x, y, z, and m.

Description

  • This function supports circular strings, curves, polyhedral surfaces, triangles, and triangulated irregular network (TIN) surfaces.
  • The ST_SwapOrdinates function supports 3D objects and does not delete z coordinates.
  • The ST_SwapOrdinates function supports m coordinates.

Examples

Process a geometry object by using the default parameter settings.
SELECT ST_AsText(ST_SwapOrdinates('POINT(1 0)'::geometry,'xy'));
 st_astext
------------
 POINT(0 1)
(1 row)