ST_SwapOrdinates

更新时间:
复制 MD 格式

Swaps two coordinate axes of a geometry object.

Syntax

geometry ST_SwapOrdinates(geometry geom, cstring ords)

Parameters

ParameterDescription
geomThe geometry object whose coordinates to swap.
ordsA 2-character string identifying the two axes to swap. Valid characters: x, y, z, and m.

Supported geometry types

ST_SwapOrdinates supports the following geometry types:

  • Circular strings and curves

  • Polyhedral surfaces

  • Triangles and triangulated irregular network (TIN) surfaces

  • 3D objects (z coordinates are preserved, not dropped)

  • Geometries with m coordinates

Examples

Swap x and y coordinates

SELECT ST_AsText(ST_SwapOrdinates('POINT(1 0)'::geometry, 'xy'));

Output:

 st_astext
------------
 POINT(0 1)
(1 row)