Swaps two coordinate axes of a geometry object.
Syntax
geometry ST_SwapOrdinates(geometry geom, cstring ords)Parameters
| Parameter | Description |
|---|---|
geom | The geometry object whose coordinates to swap. |
ords | A 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)该文章对您有帮助吗?